Ejemplo n.º 1
0
        public override string FormatReload(int index, string cellVar, string className, string sheetName, string columnName)
        {
            string attribute = MetaSheets.GetName_Variable(columnName);
            string prefix    = GetEnumPrefix(className, sheetName, columnName);
            string varA      = string.Format("tmp{0}", index);

            return(StringUtilities.Format(@"
				List<{1}> {2} = new List<{1}>();
				foreach(string val in columns[{0}].Split(',')) {
					if(val.Trim().Length > 0) {
						{2}.Add(({1})System.Enum.Parse(typeof({1}), GetCamelCase(val)));
					}
				}
				_rows[i].{3} = {2}.ToArray();		//prefix: '"                     + prefix + "' columnName: '" + columnName + "'",
                                          index,
                                          prefix,
                                          varA,
                                          attribute
                                          ));
        }
Ejemplo n.º 2
0
        public override string FormatReload(int index, string cellVar, string className, string sheetName, string columnName)
        {
            string attribute = MetaSheets.GetName_Variable(columnName);

            return(StringUtilities.Format(@"
				Debug.Log("">> ""+{2});
				if( {2}.Trim().Length > 0 ) {
					int[] tmp{0} = Array.ConvertAll( {2}.Split('/'), int.Parse);
					if(tmp{0}.Length == 3 && tmp{0}[0].ToString().Length == 4){
						_rows[i].{1} = new DateTime( tmp{0}[0], tmp{0}[1], tmp{0}[2] );//YYYY/MM/DD
					}else if(tmp{0}.Length == 3 && tmp{0}[2].ToString().Length == 4){
						_rows[i].{1} = new DateTime( tmp{0}[2], tmp{0}[1], tmp{0}[0] );//DD/MM/YYYY
					}else{
						Debug.LogError(""Wrong format for DateTime cell '{2}'"");
					}
				}
				"                ,
                                          index,
                                          attribute,
                                          cellVar
                                          ));
        }
Ejemplo n.º 3
0
        public override string FormatReload(int index, string cellVar, string className, string sheetName, string columnName)
        {
            string attribute = MetaSheets.GetName_Variable(columnName);
            string tempVar1  = "tmp" + index;
            string tempVar2  = "tmp" + index + "b";

            return(StringUtilities.Format(@"
					Color {0};
					string[] {1} = CleanString({2}).Split(',');
					_rows[i].{3} = new Color[{1}.Length];
					for (j = 0; j < {1}.Length; j++) {
						if(TryParseColor({1}[j], out {0})){
							_rows[i].{3}[j] = {0};
						}else{
							_rows[i].{3}[j] = Color.black;
						}
					}"                    ,
                                          tempVar1,
                                          tempVar2,
                                          cellVar,
                                          attribute
                                          ));
        }
Ejemplo n.º 4
0
        private static bool OnGUI_BuildSettings(EditorWindow window, Configuration configuration)
        {
            EditorGUILayout.Space();
            GUILayout.BeginHorizontal();
            string className = EditorGUILayout.TextField(new GUIContent("Class Name", MetaSheetsImages.IconClass), configuration.className, GUILayout.ExpandWidth(true));

            if (className != configuration.className)
            {
                configuration.className = className;
                return(true);
            }
            GUILayout.Label(".cs", GUILayout.ExpandWidth(true));
            GUILayout.EndHorizontal();
            //Reload Code Options
            bool doAddReloadCode = EditorGUILayout.Toggle(new GUIContent("Add reload code", Copy.copy.tooltip_addReloadCode.Copy(configuration.className)), configuration.doAddReloadCode);

            if (doAddReloadCode != configuration.doAddReloadCode)
            {
                configuration.doAddReloadCode = doAddReloadCode;
                return(true);
            }
            EditorGUILayout.BeginHorizontal();
            if (doAddReloadCode)
            {
                string proxyURL = EditorGUILayout.TextField(new GUIContent("Proxy URL", Copy.copy.tooltip_proxyURL), configuration.proxyURL);
                if (proxyURL != configuration.proxyURL)
                {
                    configuration.proxyURL = proxyURL;
                    return(true);
                }
                GUI.enabled = proxyURL.Length > 0 && configuration.documentKey != "";
                if (GUILayout.Button("Test", GUILayout.ExpandWidth(false)))
                {
                    Application.OpenURL(proxyURL + "" + WWW.EscapeURL(configuration.DocumentURL));
                }
                GUI.enabled = true;
            }
            EditorGUILayout.EndHorizontal();
            //Don't allow to build when Unity is playing in the Editor
            if (Application.isPlaying)
            {
                GUI.enabled = false;
            }
            //Class name has to be defined
            if (configuration.className.Length == 0)
            {
                GUI.enabled = false;
            }
            //Document key has to be defined
            if (configuration.documentKey.Length == 0)
            {
                GUI.enabled = false;
            }
            if (UiButton("Generate \"" + configuration.className + ".cs\"", Copy.copy.tooltip_generateCode.Copy(configuration.className), MetaSheetsImages.IconGenerate))
            {
                //Save Settings
                MetaSheets.configuration.Apply(configuration);
                MetaSheets.Save();
                MetaSheets.Build(configuration, window);
            }
            GUI.enabled = true;
            return(false);
        }
Ejemplo n.º 5
0
 public override string GetValue(string cell, string className, string sheetName, string columnName)
 {
     cell = Trim(cell);
     string[] array_label = columnName.Split(' ');            //CONTENT OF THE COLUMN LABEL SPLIT BY SPACE
     if (array_label.Length == 2)
     {
         //string classNameSheet	= GetName_ClassRow(array_label[0].Replace("[","").Replace("]",""));
         //string varName			= GetName_Variable(columnName);
         string        constructor = "new " + MetaSheets.GetName_ClassSheetNameSpace(className) + "." + MetaSheets.GetName_ClassRow(array_label[0]) + "{ {0} }";
         string        classSheet  = columnName.Split(' ').First().Replace("[", "").Replace("]", "");
         string[]      array       = cell.Split(',');     //SPLIT CELL-ARRAY ELEMENTS BY ','
         List <string> list        = new List <string>();
         bool          isError     = false;
         foreach (string item in array)
         {
             string[] array_item = item.Trim().Split('.');                    //CONTENT OF THE CELL SPLIT BY '.'
             if (item.Trim().Length == 0)
             {
                 list.Add("null");
             }
             else if (array_item.Length == 2)
             {
                 list.Add(className + "." + item);
             }
             else if (array_item.Length == 1)
             {
                 list.Add(className + "." + classSheet + "." + item);
             }
             else
             {
                 //ERROR DOES NOT MATCH UP
                 isError = true;
             }
         }
         if (isError)
         {
             // SOMETHING WENT WRONG, INFORM THE USER
             string format;
             if (array_label.Length >= 1)
             {
                 format = classSheet + ".idA, " + classSheet + ".idB";
             }
             else
             {
                 format = "mySheetId.idA, mySheetId.idB";
             }
             Copy.copy.help_wrongClassArrayItem.ShowHelp(Help.eImage.cellWrongClassArray, sheetName, cell, format);
         }
         return(StringUtilities.Format(constructor, string.Join(", ", list.ToArray())));
     }
     return("null");           //DEFAULT VALUE FOR WHEN NO CLASS COULD BE DETERMINED
 }