LogCode() public static method

public static LogCode ( string name, string message ) : void
name string
message string
return void
Beispiel #1
0
//  void rightPanel()
//  {
//      //GUI.BeginGroup(errorPanel.getRect());
//      GUI.BeginGroup(new Rect(Screen.width*3/4+5,0,Screen.width*1/4-5,Screen.height));
//      if (GUI.Button (new Rect (10,15,130,65), "Back", button_style))
//      {
//          if (!shouldPopup) {
//              //back button will change the SpellBook page name
//              input.SetCode(current_code);
//
//              enabled = false;
//              previous_state.active = true;
//              paused = true;
//              Time.timeScale = 1;
//
//              ProgramLogger.LogKV("close", getSpellName()+", "+Time.time);
//              ProgramLogger.LogCode(getSpellName(), current_code);
//
//              if(IDEClosed != null)
//                  IDEClosed(file_name, current_code);
//          }
//      }
//
//
//      if (GUI.Button (new Rect (180,15,65,65), "X", remove_style))
//      {
//          no_edit = true;
//          shouldPopup = true;
//      }
//
// //       GUIStyle style = GUI.skin.box;
// //
// //       style.alignment = TextAnchor.UpperLeft;
// //       style.wordWrap = true;
// //
// //       string pattern = @"^(.+) class (.+) is public, should be declared in a file named (.+)";
// //       if (!Regex.IsMatch(current_error, pattern))
// //           GUI.Box(new Rect (10,100,230,500), current_error, style);
// //       else {
// //           GUI.Box(new Rect (10,100,230,500), "------------", style);
// //       }
//
//      GUI.EndGroup();
//  }

    public void checkBackButton(Rect r)
    {
        if (GUI.Button(r, "Back", button_style))
        {
            if (!shouldPopup)
            {
                //back button will change the SpellBook page name
                input.SetCode(current_code);

                enabled = false;
                previous_state.active = true;
                paused         = true;
                Time.timeScale = 1;

                ProgramLogger.LogKVtime("close", getSpellName());                 //+", "+Time.time);
                ProgramLogger.LogCode(getSpellName(), current_code);
                SpellLogger.LogCode(getSpellName(), current_code);

                if (IDEClosed != null)
                {
                    IDEClosed(file_name, current_code);
                }
            }
        }
    }
Beispiel #2
0
    string givePlayerAScroll()
    {
        CodeScrollItem item;

        GameObject initial_scroll = new GameObject();

        initial_scroll.name = "InitialScroll";
        initial_scroll.AddComponent <CodeScrollItem>();
        item                  = initial_scroll.GetComponent <CodeScrollItem>();
        item.item_name        = "Blank";
        item.inventoryTexture = Resources.Load("Textures/Scroll") as Texture2D;

        if (!copied_spells.ContainsKey(currentPage().getName()))
        {
            copied_spells.Add(currentPage().name, 0);
        }


        int number_so_far = copied_spells[currentPage().getName()];
        int number        = number_so_far + 1;

        copied_spells[currentPage().name]++;

        CodeScrollItem code_scroll_item_component = initial_scroll.GetComponent <CodeScrollItem>();

        code_scroll_item_component.setCurrentFile(currentPage().getName() + number + ".java");

        code_scroll_item_component.getIDEInput().SetCode(currentPage().code.Replace(currentPage().getName(), currentPage().getName() + number));

        ProgramLogger.LogCode(currentPage().getName() + number, code_scroll_item_component.getIDEInput().GetCode());
        SpellLogger.LogCode(currentPage().getName() + number, code_scroll_item_component.getIDEInput().GetCode());

        GameObject.Find("Inventory").GetComponent <Inventory>().addItem(initial_scroll);
        return(currentPage().getName() + number + ".java");
    }
Beispiel #3
0
 void OnApplicationQuit()
 {
     if (enabled)
     {
         input.SetCode(current_code);
         ProgramLogger.LogKVtime("close", getSpellName()); //+", "+Time.time);
         ProgramLogger.LogCode(getSpellName(), current_code);
         SpellLogger.LogCode(getSpellName(), current_code);
     }
 }
Beispiel #4
0
 public void checkNewSpellButton(Rect r)
 {
     if (GUI.Button(r, left_panel_background, empty_style))
     {
         input.SetCode(current_code);
         ProgramLogger.LogKVtime("close", getSpellName());     //+", "+Time.time);
         ProgramLogger.LogCode(getSpellName(), current_code);
         SpellLogger.LogCode(getSpellName(), current_code);
         if (IDEClosed != null)
         {
             IDEClosed(file_name, current_code);
         }
         string fname = spellbook.copyBlankSpell();
         SetInput(new EclipseInput("CodeSpellsJava", JuneConfig.java_files_path + "/" + fname));
         ProgramLogger.LogKVtime("open", getSpellName());     //+", "+Time.time);
         if (IDEOpened != null)
         {
             IDEOpened(file_name, current_code);
         }
     }
 }
Beispiel #5
0
    void givePlayerExistingSpells()
    {
//             System.Diagnostics.Process reader = Shell.shell_no_start("./buildSpellsLog.py", "CodeSpellsProgram.log CodeSpellsSpells.log");
//             reader.Start();
//             reader.WaitForExit();
//             reader.Close();
        Spellbook spellbook = GameObject.Find("Spellbook").GetComponent <Spellbook>();
        Inventory inventory = GameObject.Find("Inventory").GetComponent <Inventory>();

        if (SpellLogger.loggedSpells.Length > 0)
        {
            string[] parts, keyed;
            foreach (string line in SpellLogger.loggedSpells)
            {
                keyed = line.Split(new char[] { ':' });
                if (keyed.Length == 1)      //support for old spell log formats
                {
                    parts = line.Split(new char[] { ',' });
                    if (parts.Length == 1)
                    {
                        spellbook.addExistingSpell(line, "");
                    }
                    else
                    {
                        byte[] bs   = System.Convert.FromBase64String(parts[1].Trim());
                        string code = System.Text.Encoding.UTF8.GetString(bs, 0, bs.Length);
                        spellbook.addExistingSpell(parts[0].Trim(), code);
                    }
                }
                else
                {
                    parts = keyed[1].Split(new char[] { ',' });
                    if (keyed[0] == "code")
                    {
                        byte[] bs   = System.Convert.FromBase64String(parts[1].Trim());
                        string code = System.Text.Encoding.UTF8.GetString(bs, 0, bs.Length);
                        spellbook.addExistingSpell(parts[0].Trim(), code);
                    }
                    else if (keyed[0] == "rename")
                    {
                        string old  = parts[0].Trim();
                        string newn = parts[1].Trim();
                        //this could perhaps instead be accomplished with File.Move(...)
//                         List<GameObject> matching_items = inventory.getMatching(old);
//                         if (matching_items.Count != 1) {
//                             Debug.Log("matching_items length "+matching_items.Count);
//                             continue;
//                         }
                        CodeScrollItem item = inventory.getCodeScrollItem(old).GetComponent <CodeScrollItem>();
                        //CodeScrollItem item = matching_items[0].GetComponent<CodeScrollItem>();
//                         if (item == null) {
//                             Debug.Log("Renaming CodeScrollItem null");
//                             continue;
//                         } else
//                             Debug.Log("Renaming CodeScrollItem "+item.getName());
                        string code = item.getIDEInput().GetCode();
                        item.setCurrentFile(newn + ".java");
                        item.getIDEInput().SetCode(code);
                        spellbook.setNameCounter(newn);
                    }
                    else if (keyed[0] == "delete")
                    {
                        List <GameObject> matching_items = inventory.getMatching(parts[0].Trim());
                        if (matching_items.Count > 0)
                        {
                            Debug.Log("matching items: " + matching_items.Count);
                            inventory.removeItem(matching_items[0]);
                        }
                    }
                }
            }
            inventory.clearRemovedItems();
            foreach (CodeScrollItem item in inventory.getAllCodeScrollItems())
            {
                string code = item.getIDEInput().GetCode();
                SpellLogger.LogCode(item.getName(), code);
            }
        }
//             if (File.Exists("./CodeSpellsSpells.log")) {
//             string[] lines = File.ReadAllLines("./CodeSpellsSpells.log");
//             Spellbook spellbook = GameObject.Find("Spellbook").GetComponent<Spellbook>();
//             string[] parts;
//             foreach (string line in lines) {
//                 parts = line.Split(new char[] {','});
//                 if (parts.Length == 1)
//                         spellbook.addExistingSpell(line, "");
//                     else {
//                         byte[] bs = System.Convert.FromBase64String(parts[1].Trim());
//                         string code = System.Text.Encoding.UTF8.GetString(bs, 0, bs.Length);
//                         spellbook.addExistingSpell(parts[0].Trim(), code);
//                     }
//                 }
//             }
    }