Skip to content

Commit

Permalink
Fixing bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
Vito217 committed Jul 19, 2021
1 parent de7cfe7 commit af03433
Show file tree
Hide file tree
Showing 23 changed files with 18,410 additions and 1,742 deletions.
4 changes: 2 additions & 2 deletions Assets/Resources/Prefabs/Static/UI/JavascriptEditor.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -2574,8 +2574,8 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
m_TargetAssemblyTypeName: REditor, Assembly-CSharp
- m_Target: {fileID: 5643977694741393565}
m_TargetAssemblyTypeName: JavascriptEditor, Assembly-CSharp
m_MethodName: Save
m_Mode: 1
m_Arguments:
Expand Down
12 changes: 8 additions & 4 deletions Assets/Resources/Prefabs/Static/UI/Transcript.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ RectTransform:
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 533, y: 300}
m_SizeDelta: {x: 600, y: 400}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &2202359507917057684
MonoBehaviour:
Expand All @@ -315,9 +315,8 @@ MonoBehaviour:
field: {fileID: 5517324446377372436}
keyboardTarget: {fileID: 0}
lineCounter: {fileID: 0}
loadingWheel: {fileID: 0}
keyboardsGameObject: {fileID: 0}
freezeRotation: 1
loadingWheels: []
--- !u!223 &6877927472131900574
Canvas:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -462,7 +461,7 @@ RectTransform:
m_GameObject: {fileID: 903777686569549383}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1.2, y: 1.2, z: 1.2}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 5563143028087264128}
- {fileID: 5024933862735060497}
Expand Down Expand Up @@ -2447,6 +2446,11 @@ PrefabInstance:
propertyPath: m_AnchorMax.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2089797138330010477, guid: 49284f16fccc7ef49bc9c625b19f6c36,
type: 3}
propertyPath: m_AnchorMin.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 2693525693033378811, guid: 49284f16fccc7ef49bc9c625b19f6c36,
type: 3}
propertyPath: m_fontSize
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ MonoBehaviour:
m_fontSizeMax: 72
m_fontStyle: 0
m_HorizontalAlignment: 1
m_VerticalAlignment: 512
m_VerticalAlignment: 256
m_textAlignment: 65535
m_characterSpacing: 0
m_wordSpacing: 0
Expand Down Expand Up @@ -1493,7 +1493,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
m_IsActive: 0
--- !u!224 &7825538734447538305
RectTransform:
m_ObjectHideFlags: 0
Expand All @@ -1509,10 +1509,10 @@ RectTransform:
m_Father: {fileID: 7450160830204829913}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 361, y: -120.333336}
m_SizeDelta: {x: 361, y: 120.333336}
m_Pivot: {x: 1, y: 0}
--- !u!222 &2818295236404415074
CanvasRenderer:
Expand Down Expand Up @@ -1596,7 +1596,7 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
- m_Target: {fileID: 8947788703033765450}
m_TargetAssemblyTypeName: Playground, Assembly-CSharp
m_MethodName: Inspect
m_Mode: 1
Expand Down Expand Up @@ -2697,7 +2697,7 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
- m_Target: {fileID: 8947788703033765450}
m_TargetAssemblyTypeName: Playground, Assembly-CSharp
m_MethodName: PharoDo
m_Mode: 1
Expand Down Expand Up @@ -3765,8 +3765,15 @@ MonoBehaviour:
keyboardTarget: {fileID: 5123573550139232984}
lineCounter: {fileID: 827000592675701620}
freezeRotation: 0
loadingWheels: []
codeCubePrefab: {fileID: 0}
loadingWheels:
- {fileID: 344152797566447684}
- {fileID: 8433457910611720007}
- {fileID: 4864773597692323512}
- {fileID: 2331904214549689930}
- {fileID: 8158657527528815512}
- {fileID: 1909295088220853846}
codeCubePrefab: {fileID: 5573314057497506692, guid: abb334ab8c7e48c47913669eeab92697,
type: 3}
metrics: {fileID: 3920583410558807829}
--- !u!1 &7804756461454528152
GameObject:
Expand Down Expand Up @@ -4059,7 +4066,7 @@ MonoBehaviour:
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 0}
- m_Target: {fileID: 8947788703033765450}
m_TargetAssemblyTypeName: Playground, Assembly-CSharp
m_MethodName: PharoPrint
m_Mode: 1
Expand Down
29 changes: 27 additions & 2 deletions Assets/Scripts/UI/Objects/FileExplorer/JavascriptEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,33 @@ public class JavascriptEditor : InitializeBehaviour

Dictionary<string, Color> colorDict = new Dictionary<string, Color>()
{
{ "<-", Color.green },
{ "print", Color.green }
{ "break", Color.magenta },
{ "case", Color.magenta } ,
{ "catch", Color.magenta} ,
{ "continue", Color.magenta},
{ "debugger", Color.magenta},
{ "default", Color.magenta},
{ "delete", Color.magenta},
{ "do",Color.magenta } ,
{ "else", Color.magenta},
{ "finally",Color.magenta },
{ "for", Color.magenta},
{ "function" , Color.magenta},
{ "if", Color.magenta},
{ "in",Color.magenta },
{ "instanceof" , Color.magenta},
{ "new", Color.magenta},
{ "return", Color.magenta},
{ "switch" , Color.magenta},
{ "this" , Color.magenta},
{ "throw" , Color.magenta},
{ "try" , Color.magenta},
{ "typeof" , Color.magenta},
{ "var" , Color.magenta},
{ "void", Color.magenta},
{ "while", Color.magenta},
{ "and", Color.magenta},
{ "with" , Color.magenta}
};

public override IEnumerator innerStart()
Expand Down
83 changes: 47 additions & 36 deletions Assets/Scripts/UI/Objects/Playground.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,42 +95,7 @@ public async void PharoDo()
}
else if (!string.IsNullOrWhiteSpace(selectedCode))
{
float width = GetComponent<RectTransform>().sizeDelta.x *
transform.Find("Panel").GetComponent<RectTransform>().localScale.x;

PharoClassCodeCube cube = Instantiate(codeCubePrefab);
cube.transform.position = transform.TransformPoint(width, 0f, 0f);
cube.transform.forward = transform.forward;

string selection = getSelectedCode(field.text, false);
string res = await Pharo.Inspect(selection);

logText.text = res;

res = res.Replace("an OrderedCollection('", "");
res = res.Replace("')", "");

string[] vars = res.Split(new string[] { "' '" }, StringSplitOptions.None);
foreach (string tuple in vars)
{
string[] pair = tuple.Replace("'", "").Split('=');
string type = pair[1].Replace("a ", "");
string obj = pair[0];

if (obj == "self")
{
string code = "RPackageOrganizer packageOrganizer packageOfClassNamed: '" + type + "' .";
string resPack = await Pharo.Execute(code);
string packageName = Regex.Replace(resPack, @"a RPackage\(([a-zA-Z0-9]+)\)", "$1");

cube.className = type;
cube.packageName = packageName;
}
else
{
cube.instVarsTypes.Add(type);
}
}
GenerateCodeCube();
}
}
catch (Exception e)
Expand Down Expand Up @@ -371,4 +336,50 @@ void HighlightCode()
{

}

async void GenerateCodeCube()
{
PharoClassCodeCube cube = InstantiateCube();
string selection = getSelectedCode(field.text, false);
string res = await Pharo.Inspect(selection);

logText.text = res;

res = res.Replace("an OrderedCollection('", "");
res = res.Replace("')", "");

string[] vars = res.Split(new string[] { "' '" }, StringSplitOptions.None);
foreach (string tuple in vars)
{
string[] pair = tuple.Replace("'", "").Split('=');
string type = pair[1].Replace("a ", "");
string obj = pair[0];

if (obj == "self")
{
string code = "RPackageOrganizer packageOrganizer packageOfClassNamed: '" + type + "' .";
string resPack = await Pharo.Execute(code);
string packageName = Regex.Replace(resPack, @"a RPackage\(([a-zA-Z0-9]+)\)", "$1");

cube.className = type;
cube.packageName = packageName;
}
else
{
cube.instVarsTypes.Add(type);
}
}
}

public virtual PharoClassCodeCube InstantiateCube()
{
float width = GetComponent<RectTransform>().sizeDelta.x *
transform.Find("Panel").GetComponent<RectTransform>().localScale.x;

PharoClassCodeCube cube = Instantiate(codeCubePrefab);
cube.transform.position = transform.TransformPoint(width, 0f, 0f);
cube.transform.forward = transform.forward;

return cube;
}
}
9 changes: 9 additions & 0 deletions Assets/Scripts/UI/WindowCubes/PlaygroundWindowCube.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,13 @@ void UpdateMetrics()
{
metrics.text = "Number of lines of code: " + field.text.Count(c => c == '\n');
}

public override PharoClassCodeCube InstantiateCube()
{
PharoClassCodeCube cube = Instantiate(codeCubePrefab);
cube.transform.position = transform.TransformPoint(1f, 0f, -1f);
cube.transform.forward = transform.forward;

return cube;
}
}
Loading

0 comments on commit af03433

Please sign in to comment.