From 5f023fdfd341059e02c2aed8d83b04f5bd8ec5a1 Mon Sep 17 00:00:00 2001 From: Ryan Date: Wed, 20 Sep 2017 11:24:53 -0400 Subject: [PATCH] 1.4.2 (Internal Activation) --- parseManager/Program.cs | 2 +- parseManager/bin/Debug/choiceTest.txt | 17 +- parseManager/bin/Debug/parsetest2.txt | 2 +- parseManager/bin/Debug/savedata.dat | Bin 3850 -> 3925 bytes ...eManagerTester.csproj.FileListAbsolute.txt | 10 ++ parseManager/parseManager.cs | 148 ++++++++++++++---- 6 files changed, 138 insertions(+), 41 deletions(-) diff --git a/parseManager/Program.cs b/parseManager/Program.cs index c63c381..a7de23b 100644 --- a/parseManager/Program.cs +++ b/parseManager/Program.cs @@ -18,7 +18,7 @@ namespace parseManagerCS [STAThread] public static void Main(string[] args) { - //args=new string[]{"choiceTest.txt"}; + args=new string[]{"choiceTest.txt"}; string file; string print = ""; List temp = new List(); diff --git a/parseManager/bin/Debug/choiceTest.txt b/parseManager/bin/Debug/choiceTest.txt index 58e9cdd..941104c 100644 --- a/parseManager/bin/Debug/choiceTest.txt +++ b/parseManager/bin/Debug/choiceTest.txt @@ -1,4 +1,4 @@ -VERSION 1.3.2 +VERSION 1.4.1 THREAD testthread.txt [PLAYGAME]{ print("Welcome to my game!") @@ -37,12 +37,11 @@ THREAD testthread.txt "So your name is $name$, thats cool!" pos=1 sleep(200) - SAVE("savedata.dat") ::loop:: - clear() SAVE("savedata.dat") + writeAt("",0,0) setFG(Color_Blue) - fancy(" What to do $name$? Time plsyed $hours_played$:$mins_played$:$secs_played$,/l, Play Game, View Stats, View Credits, Quit Game") + fancy(" What to do $name$? Time played $hours_played:00$:$mins_played:00$:$secs_played:00$,/l, Play Game, View Stats, View Credits, Quit Game") keyUP=isDown("{UP}") keyDOWN=isDown("{DOWN}") keyENTER=isDown("{ENTER}") @@ -50,7 +49,7 @@ THREAD testthread.txt if keyDOWN==true then setVarPlay("pos",pos+1)|SKIP(0) if keyENTER==true then GOTO("choicemade")|SKIP(0) writeAt("->",1,pos+2) - sleep(75) + sleep(25) GOTO("loop") ::choicemade:: playSong(snd_select) @@ -69,8 +68,8 @@ THREAD testthread.txt if keyENTER==true then SKIP(0)|GOTO("loop") print(" ") } -[testFunc:function(a)]{ - "Invoke Test: $a$!" +[testfunc:function(testing)]{ + "" } [setVarPlay:function(var,val)]{ setVar(var,val) @@ -79,9 +78,9 @@ THREAD testthread.txt beep() GOTO("end") ::toolittle:: - setVar("pos",1) + setVar("pos",4) GOTO("end") ::toomuch:: - setVar("pos",4) + setVar("pos",1) ::end:: } \ No newline at end of file diff --git a/parseManager/bin/Debug/parsetest2.txt b/parseManager/bin/Debug/parsetest2.txt index 991a866..6824ca5 100644 --- a/parseManager/bin/Debug/parsetest2.txt +++ b/parseManager/bin/Debug/parsetest2.txt @@ -1,4 +1,4 @@ -VERSION 1.0 +VERSION 1.4 LOAD game/play.dat [COUNTER]{ ::loop:: diff --git a/parseManager/bin/Debug/savedata.dat b/parseManager/bin/Debug/savedata.dat index 289d07d4ae6384fd02c97d4ee13b4f557ce32f7b..42c671ef3b0bd62f84b1539062118f752ac95e69 100644 GIT binary patch delta 141 zcmeB@yDB%qlHJTy&&b%+a-+j<7AB6O&9i_@% delta 65 zcmV-H0KWg#9*Q22IR`a3E;2YdII%$c1OomNvpof30s$bipa)w70y{vH{R<)j@IR9w X44?uKK$F7^P5~5?5)Ey$$_ def._THREAD("SYSTEM_THREADED_BLOCK", this, systemThread)); + thread.Start(); + } public bool IsInternal() { return _isInternal; @@ -319,10 +331,14 @@ namespace parseManagerCS { chunk c; if (isRegisteredFunction(method, out c)) { - return InvokeI(method, args, c, true); - } - PushError("Attempt to invoke a non existing method!"); + return systemThread.InvokeI(method, args, c, true); + } + try { + return systemThread.InvokeR(method, args); + } catch { + PushError("Attempt to invoke a non existing method!"); return null; + } } public object InvokeR(string method, object[] args) { @@ -338,7 +354,9 @@ namespace parseManagerCS if (tests.Contains("Null")) { PushError("Invalid method: " + method + " (Method does not exist! Check your spelling!)"); } else if (tests.Contains("ArgumentException")) { - PushError("Invalid method: " + method + " (Check your arguments! Ensure the types are correct!)"); + PushError("Invalid method: " + method + " (Check your number of arguments!)"); + } else if (tests.Contains("mismatch")) { + PushError("Invalid method: " + method + " (Ensure the types are correct!)"); } PushError("Invalid method: " + method + " (Unknown Error! It just doesn't work!)\n\n" + e); return null; @@ -589,6 +607,7 @@ namespace parseManagerCS } public string parseHeader(string header) { + header = header.Replace(@"\$", "````"); var results = Regex.Matches(header, @"\$([\S\*]+?)\$"); int len = results.Count; string str; @@ -597,10 +616,13 @@ namespace parseManagerCS int testnum; for (int i = 0; i < len; i++) { str = results[i].Groups[1].Value; - if (str.Contains("*")) { + if (str.Contains("*") || str.Contains(":")) { var test = Regex.Match(str, @"(.+?)\*(.+)"); + var test2 = Regex.Match(str, @"(.+):(.+)"); var spart = test.Groups[1].Value; var ipart = test.Groups[2].Value; + var vpart = test2.Groups[1].Value; + var fpart = test2.Groups[2].Value; if (!isVar(spart, out temp)) { } @@ -610,8 +632,11 @@ namespace parseManagerCS } else if (isVar(ipart, out temp2)) { str = def.repeat(this, temp.ToString(), (double)temp2); header = header.Replace(results[i].ToString(), str); + } else if (isVar(vpart, out temp2) && fpart != "") { + str = def.tostring(this, (double)temp2, fpart); + header = header.Replace(results[i].ToString(), str); } else { - PushError("When using the $varname*num$ expression num must be a number or a variable that is set to a number!"); + PushError("When using the $varname*num$ expression num must be a number or a variable that is set to a number! (" + header + ")"); } } if (isVar(str, out temp)) { @@ -620,6 +645,7 @@ namespace parseManagerCS header = header.Replace(results[i].ToString(), "null"); } } + header = header.Replace("````", "$"); return header; } public object[] ResolveVar(string[] v) @@ -1073,7 +1099,7 @@ namespace parseManagerCS { _Parent = other; } - public object[] GetList() + public object[] ToArray() { var temp = new object[_varsI.Count]; var count = 0; @@ -1135,15 +1161,15 @@ namespace parseManagerCS return null; } set { - while(_busyS){ + while (_busyS) { // wait } - _busyS=true; + _busyS = true; if (!_sen) { ind = ind.ToLower(); } _vars[ind] = value; - _busyS=false; + _busyS = false; } } public object this[int ind] { @@ -1158,12 +1184,12 @@ namespace parseManagerCS return null; } set { - while(_busyI){ + while (_busyI) { // wait } - _busyI=true; + _busyI = true; _varsI[ind] = value; - _busyI=false; + _busyI = false; } } } @@ -1279,6 +1305,7 @@ namespace parseManagerCS } public static void SetMainPM(parseManager o) { + o.InitSystemThread(); _main = o; } public static parseManager GetMainPM() @@ -1389,6 +1416,34 @@ public class standardDefine next = PM.Next(); } } + public void _THREAD(string block, parseManager _PM, parseManager PM) + { + var define = _PM.GetDefine(); + var path = _PM.GetFilepath(); + if (_PM.IsInternal()) { + if (define == "NO_DEFINE") { + PM = new parseManager(path, true); + } else { + PM = new parseManager(path, define, true); + } + } else { + if (define == "NO_DEFINE") { + PM = new parseManager(path); + } else { + PM = new parseManager(path, define); + } + } + GLOBALS.AddThread(PM); + PM.makeThread(); + PM._SetDENV(_PM.GetDENV()); + PM.SetENV(_PM.GetENV()); + nextType next = PM.Next(block); + string type; + while (next.GetCMDType() != "EOF") { + type = next.GetCMDType(); + next = PM.Next(); + } + } public void _newThread(parseManager PM, string filename) { var thread = new Thread(() => _THREAD(PM, filename)); @@ -1448,6 +1503,10 @@ public class standardDefine c.SetPos((int)env[1]); setENV(PM, (ENV)env[3]); } + public string tostring(parseManager PM, double obj, string pad) + { + return obj.ToString(pad); + } public void EXIT(parseManager PM) { cleanUpAudio(); @@ -1533,7 +1592,7 @@ public class standardDefine return (double)((string)o).Length; } if (type.Contains("ENV")) { - return (double)((ENV)o).GetList().Length; + return (double)((ENV)o).ToArray().Length; } return 0; } @@ -1615,7 +1674,8 @@ public class standardDefine { return rnd.NextDouble(); } - public void randomseed(parseManager PM,double seed){ + public void randomseed(parseManager PM, double seed) + { rnd = new Random((int)seed); } public double round(parseManager PM, double num, double n) @@ -1775,20 +1835,6 @@ public class standardDefine kk = Key.Y; } else if (k == "Z") { kk = Key.Z; - } else if (k == "{UP}") { - kk = Key.Up; - } else if (k == "{DOWN}") { - kk = Key.Down; - } else if (k == "{LEFT}") { - kk = Key.Left; - } else if (k == "{RIGHT}") { - kk = Key.Right; - } else if (k == "{ENTER}") { - kk = Key.Enter; - } else if (k == "{LSHIFT}") { - kk = Key.LeftShift; - } else if (k == "{RSHIFT}") { - kk = Key.RightShift; } else if (k == "0") { kk = Key.D0; } else if (k == "1") { @@ -1809,11 +1855,53 @@ public class standardDefine kk = Key.D8; } else if (k == "9") { kk = Key.D9; + } else if (k == "{UP}") { + kk = Key.Up; + } else if (k == "{DOWN}") { + kk = Key.Down; + } else if (k == "{LEFT}") { + kk = Key.Left; + } else if (k == "{RIGHT}") { + kk = Key.Right; + } else if (k == "{ENTER}") { + kk = Key.Enter; + } else if (k == "{LSHIFT}") { + kk = Key.LeftShift; + } else if (k == "{RSHIFT}") { + kk = Key.RightShift; } else if (k == "{SPACE}") { kk = Key.Space; + } else if (k == "{F1}") { + kk = Key.F1; + } else if (k == "{F2}") { + kk = Key.F2; + } else if (k == "{F3}") { + kk = Key.F3; + } else if (k == "{F4}") { + kk = Key.F4; + } else if (k == "{F5}") { + kk = Key.F5; + } else if (k == "{F6}") { + kk = Key.F6; + } else if (k == "{F7}") { + kk = Key.F7; + } else if (k == "{F8}") { + kk = Key.F8; + } else if (k == "{F9}") { + kk = Key.F9; + } else if (k == "{F10}") { + kk = Key.F10; + } else if (k == "{F11}") { + kk = Key.F11; + } else if (k == "{F12}") { + kk = Key.F12; } return Keyboard.IsKeyDown(kk); } + public void setCursorVisibility(parseManager PM, bool v) + { + Console.CursorVisible = v; + } public void error(parseManager PM, string msg) { PM.PushError(msg);