Focus controls, and stablity improvments
Many console enhancements!
This commit is contained in:
parent
70fa89de8c
commit
8dfb0cb367
@ -5,7 +5,7 @@ TODO:
|
|||||||
- [ ] Add other cool built in things (Fun)
|
- [ ] Add other cool built in things (Fun)
|
||||||
- [ ] Add object support (Tough)
|
- [ ] Add object support (Tough)
|
||||||
- [ ] Improve audio support (Simple)
|
- [ ] Improve audio support (Simple)
|
||||||
- [ ] Add simple threading (Alright)
|
- [x] Add simple threading (Alright)
|
||||||
- [ ] Fix Bugs! (Death)
|
- [ ] Fix Bugs! (Death)
|
||||||
|
|
||||||
Maybe:
|
Maybe:
|
||||||
|
|||||||
86
parseManager/Fancy.cs
Normal file
86
parseManager/Fancy.cs
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* Created by SharpDevelop.
|
||||||
|
* User: Ryan
|
||||||
|
* Date: 8/27/2017
|
||||||
|
* Time: 8:29 PM
|
||||||
|
*
|
||||||
|
* To change this template use Tools | Options | Coding | Edit Standard Headers.
|
||||||
|
*/
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace FancyPrintCS
|
||||||
|
{
|
||||||
|
public static class Fancy
|
||||||
|
{
|
||||||
|
static char[][] fvars = {
|
||||||
|
new char[]{ '╚', '═', '╝', '║', '╔', '╗', '╠', '╣', '╩', '╦', '╬' },
|
||||||
|
new char[]{ '+', '═', '+', '|', '+', '+', '+', '+', '+', '+', '+' },
|
||||||
|
new char[]{ '└', '─', '┘', '│', '┌', '┐', '├', '┤', '┴', '┬', '┼' },
|
||||||
|
new char[]{ '+', '~', '+', '|', '+', '+', '+', '+', '+', '+', '+' },
|
||||||
|
new char[]{ '+', '-', '+', '|', '+', '+', '+', '+', '+', '+', '+' },
|
||||||
|
new char[]{ '╙', '─', '╜', '║', '╓', '╖', '╟', '╢', '╨', '╥', '╫' },
|
||||||
|
new char[]{ '╘', '═', '╛', '│', '╒', '╕', '╞', '╡', '╧', '╤', '╪' }
|
||||||
|
};
|
||||||
|
static int form = 3;
|
||||||
|
static int fvar;
|
||||||
|
public static void SetForm(int n)
|
||||||
|
{
|
||||||
|
if (n < 1 || n > 3) {
|
||||||
|
Console.WriteLine("Invalid int value! Only 1, 2 and 3");
|
||||||
|
} else {
|
||||||
|
form = n;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void SetForm(string n)
|
||||||
|
{
|
||||||
|
if (n.ToLower()=="left"){
|
||||||
|
form=2;
|
||||||
|
} else if(n.ToLower()=="right"){
|
||||||
|
form=3;
|
||||||
|
} else if(n.ToLower()=="center"){
|
||||||
|
form=1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void Print(string[] msg)
|
||||||
|
{
|
||||||
|
int max = 0;
|
||||||
|
var f = fvars[fvar];
|
||||||
|
for (int i = 0; i < msg.Length; i++) {
|
||||||
|
if (msg[i].Length > max) {
|
||||||
|
max = msg[i].Length + 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Console.WriteLine(f[4] + new String(f[1], max) + f[5]);
|
||||||
|
string space1 = "";
|
||||||
|
string space2 = "";
|
||||||
|
for (int i = 0; i < msg.Length; i++) {
|
||||||
|
if (form == 1) { // CENTER
|
||||||
|
if ((max - 2) != msg[i].Length) {
|
||||||
|
space1 = new String(' ', (max - msg[i].Length) / 2 + ((max - msg[i].Length) % 2));
|
||||||
|
space2 = new String(' ', ((max - msg[i].Length) / 2));
|
||||||
|
} else {
|
||||||
|
space1 = new String(' ', (max - msg[i].Length) / 2 + ((max - msg[i].Length) % 2));
|
||||||
|
space2 = new String(' ', ((max - msg[i].Length) / 2));
|
||||||
|
}
|
||||||
|
} else if (form == 2) { // LEFT
|
||||||
|
space1 = "";
|
||||||
|
space2 = new String(' ', max - msg[i].Length);
|
||||||
|
} else if (form == 3) { // RIGHT
|
||||||
|
space2 = "";
|
||||||
|
space1 = new String(' ', max - msg[i].Length);
|
||||||
|
}
|
||||||
|
if (msg[i] == "/l") {
|
||||||
|
Console.WriteLine(f[6] + new String(f[1], max) + f[7]);
|
||||||
|
} else {
|
||||||
|
Console.WriteLine(f[3] + space1 + msg[i] + space2 + f[3]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Console.WriteLine(f[0] + new String(f[1], max) + f[2]);
|
||||||
|
}
|
||||||
|
public static void Print(string msg)
|
||||||
|
{
|
||||||
|
var msgArr = msg.Split(',');
|
||||||
|
Fancy.Print(msgArr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -7,79 +7,161 @@
|
|||||||
* To change this template use Tools | Options | Coding | Edit Standard Headers.
|
* To change this template use Tools | Options | Coding | Edit Standard Headers.
|
||||||
*/
|
*/
|
||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Diagnostics;
|
||||||
using CSCore;
|
using System.Runtime.InteropServices;
|
||||||
using CSCore.Codecs;
|
|
||||||
using CSCore.SoundOut;
|
|
||||||
using parseManagerCS;
|
using parseManagerCS;
|
||||||
|
using System.Windows.Input;
|
||||||
public class define : standardDefine // If you want the standard methods you must include this, Also this class cannot be static!
|
public class define : standardDefine // If you want the standard methods you must include this, Also this class cannot be static!
|
||||||
{
|
{
|
||||||
double count;
|
int origRow = Console.CursorTop;
|
||||||
ISoundOut GetSoundOut()
|
int origCol = Console.CursorLeft;
|
||||||
|
public void setPosition(parseManager PM, double x, double y)
|
||||||
{
|
{
|
||||||
if (WasapiOut.IsSupportedOnCurrentPlatform)
|
Console.SetCursorPosition((int)x, (int)y);
|
||||||
return new WasapiOut();
|
|
||||||
else
|
|
||||||
return new DirectSoundOut();
|
|
||||||
}
|
}
|
||||||
IWaveSource GetSoundSource(string path)
|
public void writeAt(parseManager PM, string s, double x, double y)
|
||||||
{
|
{
|
||||||
return CodecFactory.Instance.GetCodec(path);
|
try {
|
||||||
|
Console.SetCursorPosition(origCol + (int)x, origRow + (int)y);
|
||||||
|
Console.Write(s);
|
||||||
|
} catch (ArgumentOutOfRangeException e) {
|
||||||
|
Console.Clear();
|
||||||
|
Console.WriteLine(e.Message);
|
||||||
}
|
}
|
||||||
public void _play()
|
}
|
||||||
|
public bool isDown(parseManager PM, string key)
|
||||||
{
|
{
|
||||||
string path = (string)GLOBALS.GetData("__MUSIC");
|
if(!ApplicationIsActivated()){
|
||||||
double id = (double)GLOBALS.GetData("__MUSICH");
|
return false;
|
||||||
using (IWaveSource soundSource = GetSoundSource(path)) {
|
|
||||||
using (ISoundOut soundOut = GetSoundOut()) {
|
|
||||||
soundOut.Initialize(soundSource);
|
|
||||||
GLOBALS.AddData("__MUSICH" + id, soundOut);
|
|
||||||
soundOut.Play();
|
|
||||||
soundOut.WaitForStopped();
|
|
||||||
}
|
}
|
||||||
|
Key kk = Key.Zoom;
|
||||||
|
var k = key.ToUpper();
|
||||||
|
if (k == "A") {
|
||||||
|
kk = Key.A;
|
||||||
|
} else if (k == "B") {
|
||||||
|
kk = Key.B;
|
||||||
|
} else if (k == "C") {
|
||||||
|
kk = Key.C;
|
||||||
|
} else if (k == "D") {
|
||||||
|
kk = Key.D;
|
||||||
|
} else if (k == "E") {
|
||||||
|
kk = Key.E;
|
||||||
|
} else if (k == "F") {
|
||||||
|
kk = Key.F;
|
||||||
|
} else if (k == "G") {
|
||||||
|
kk = Key.G;
|
||||||
|
} else if (k == "H") {
|
||||||
|
kk = Key.H;
|
||||||
|
} else if (k == "I") {
|
||||||
|
kk = Key.I;
|
||||||
|
} else if (k == "J") {
|
||||||
|
kk = Key.J;
|
||||||
|
} else if (k == "K") {
|
||||||
|
kk = Key.K;
|
||||||
|
} else if (k == "L") {
|
||||||
|
kk = Key.L;
|
||||||
|
} else if (k == "M") {
|
||||||
|
kk = Key.M;
|
||||||
|
} else if (k == "N") {
|
||||||
|
kk = Key.N;
|
||||||
|
} else if (k == "O") {
|
||||||
|
kk = Key.O;
|
||||||
|
} else if (k == "P") {
|
||||||
|
kk = Key.P;
|
||||||
|
} else if (k == "Q") {
|
||||||
|
kk = Key.Q;
|
||||||
|
} else if (k == "R") {
|
||||||
|
kk = Key.R;
|
||||||
|
} else if (k == "S") {
|
||||||
|
kk = Key.S;
|
||||||
|
} else if (k == "T") {
|
||||||
|
kk = Key.T;
|
||||||
|
} else if (k == "U") {
|
||||||
|
kk = Key.U;
|
||||||
|
} else if (k == "V") {
|
||||||
|
kk = Key.V;
|
||||||
|
} else if (k == "W") {
|
||||||
|
kk = Key.W;
|
||||||
|
} else if (k == "X") {
|
||||||
|
kk = Key.X;
|
||||||
|
} else if (k == "Y") {
|
||||||
|
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"){
|
||||||
|
kk = Key.D1;
|
||||||
|
} else if (k == "2"){
|
||||||
|
kk = Key.D2;
|
||||||
|
} else if (k == "3"){
|
||||||
|
kk = Key.D3;
|
||||||
|
} else if (k == "4"){
|
||||||
|
kk = Key.D4;
|
||||||
|
} else if (k == "5"){
|
||||||
|
kk = Key.D5;
|
||||||
|
} else if (k == "6"){
|
||||||
|
kk = Key.D6;
|
||||||
|
} else if (k == "7"){
|
||||||
|
kk = Key.D7;
|
||||||
|
} else if (k == "8"){
|
||||||
|
kk = Key.D8;
|
||||||
|
} else if (k == "9"){
|
||||||
|
kk = Key.D9;
|
||||||
|
} else if(k == "{SPACE}"){
|
||||||
|
kk = Key.Space;
|
||||||
}
|
}
|
||||||
|
return Keyboard.IsKeyDown(kk);
|
||||||
}
|
}
|
||||||
public void STOP(parseManager PM, double id)
|
public string isPressing(parseManager PM)
|
||||||
{
|
{
|
||||||
var sound = (ISoundOut)GLOBALS.GetData("__MUSICH" + id);
|
return Console.ReadKey(true).Key.ToString();
|
||||||
sound.Stop();
|
|
||||||
}
|
}
|
||||||
public void RESUME(parseManager PM, double id)
|
public static bool ApplicationIsActivated()
|
||||||
{
|
{
|
||||||
var sound = (ISoundOut)GLOBALS.GetData("__MUSICH" + id);
|
var activatedHandle = GetForegroundWindow();
|
||||||
sound.Resume();
|
if (activatedHandle == IntPtr.Zero) {
|
||||||
|
return false; // No window is currently activated
|
||||||
|
} else {
|
||||||
|
var procId = Process.GetCurrentProcess().Id;
|
||||||
|
int activeProcId;
|
||||||
|
GetWindowThreadProcessId(activatedHandle, out activeProcId);
|
||||||
|
return activeProcId == procId;
|
||||||
}
|
}
|
||||||
public void SETV(parseManager PM, double id, double vol)
|
|
||||||
{
|
|
||||||
var sound = (ISoundOut)GLOBALS.GetData("__MUSICH" + id);
|
|
||||||
sound.Volume = (float)vol;
|
|
||||||
}
|
|
||||||
public void PAUSE(parseManager PM, double id)
|
|
||||||
{
|
|
||||||
var sound = (ISoundOut)GLOBALS.GetData("__MUSICH" + id);
|
|
||||||
sound.Pause();
|
|
||||||
}
|
|
||||||
public double PLAY(parseManager PM, string filepath)
|
|
||||||
{
|
|
||||||
GLOBALS.AddData("__MUSIC", filepath);
|
|
||||||
GLOBALS.AddData("__MUSICH", count++);
|
|
||||||
var oThread = new Thread(new ThreadStart(_play));
|
|
||||||
oThread.Start();
|
|
||||||
return count - 1;
|
|
||||||
}
|
}
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
|
||||||
|
static extern IntPtr GetForegroundWindow();
|
||||||
|
|
||||||
|
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
|
||||||
|
static extern int GetWindowThreadProcessId(IntPtr handle, out int processId);
|
||||||
}
|
}
|
||||||
namespace parseManagerCS
|
namespace parseManagerCS
|
||||||
{
|
{
|
||||||
class Program
|
class Program
|
||||||
{
|
{
|
||||||
|
[STAThread]
|
||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
if (args.Length == 0) {
|
// if (args.Length == 0) {
|
||||||
Console.Write("Please Include a file path!");
|
// Console.Write("Please Include a file path!");
|
||||||
Console.ReadLine();
|
// Console.ReadLine();
|
||||||
Environment.Exit(0);
|
// Environment.Exit(0);
|
||||||
}
|
// }
|
||||||
parseManager PM = new parseManager(args[0], "define");
|
parseManager PM = new parseManager("parsetest2.txt", "define");
|
||||||
nextType next = PM.Next();
|
nextType next = PM.Next();
|
||||||
string type;
|
string type;
|
||||||
while (next.GetCMDType() != "EOF") {
|
while (next.GetCMDType() != "EOF") {
|
||||||
|
|||||||
@ -1,13 +1,48 @@
|
|||||||
ENTRY START
|
ENTRY STARTHERE
|
||||||
[START]{
|
[STARTHERE]{
|
||||||
"Hello"
|
write("Name: ")
|
||||||
song=PLAY("test.flac")
|
name=getInput()
|
||||||
print("Hello!")
|
clear()
|
||||||
"Don't hit enter!"
|
if name=="" then SKIP(-4)|SKIP(0)
|
||||||
"Am I still going?"
|
PAUSE("So your name is $name$, thats cool!")
|
||||||
PAUSE(song)
|
pos=1
|
||||||
"I'm alive!"
|
::loop::
|
||||||
"Lets resume"
|
clear()
|
||||||
RESUME(song)
|
setFG(Color_Blue)
|
||||||
":)"
|
fancy("left"," What to do $name$?,/l, Play Game, View Stats, View Credits, Quit Game")
|
||||||
|
keyUP=isDown("{UP}")
|
||||||
|
keyDOWN=isDown("{DOWN}")
|
||||||
|
keyENTER=isDown("{RIGHT}")
|
||||||
|
if keyUP==true then setVarPlay("pos",pos-1)|SKIP(0)
|
||||||
|
if keyDOWN==true then setVarPlay("pos",pos+1)|SKIP(0)
|
||||||
|
if keyENTER==true then GOTO("choicemade")|SKIP(0)
|
||||||
|
writeAt("->",1,pos+2)
|
||||||
|
sleep(75)
|
||||||
|
GOTO("loop")
|
||||||
|
::choicemade::
|
||||||
|
if pos==1 then print("You Pressed Play!")|SKIP(0)
|
||||||
|
if pos==2 then print("You Pressed Stats")|SKIP(0)
|
||||||
|
if pos==3 then print("You Pressed Credits")|SKIP(0)
|
||||||
|
if pos==4 then print("You Pressed Quit")|SKIP(0)
|
||||||
|
PAUSE("Tests done (Press Enter!)")
|
||||||
|
}
|
||||||
|
[PAUSE:function(msg)]{
|
||||||
|
write(msg)
|
||||||
|
::loop::
|
||||||
|
keyENTER=isDown("{ENTER}")
|
||||||
|
if keyENTER==true then SKIP(0)|GOTO("loop")
|
||||||
|
print(" ")
|
||||||
|
}
|
||||||
|
[setVarPlay:function(var,val)]{
|
||||||
|
setVar(var,val)
|
||||||
|
if pos<1 then GOTO("toolittle")|SKIP(0)
|
||||||
|
if pos>4 then GOTO("toomuch")|SKIP(0)
|
||||||
|
beep()
|
||||||
|
GOTO("end")
|
||||||
|
::toolittle::
|
||||||
|
setVar("pos",1)
|
||||||
|
GOTO("end")
|
||||||
|
::toomuch::
|
||||||
|
setVar("pos",4)
|
||||||
|
::end::
|
||||||
}
|
}
|
||||||
@ -1,29 +1,28 @@
|
|||||||
ENTRY TESTSTART
|
ENTRY TESTSTART
|
||||||
[TESTSTART]{
|
[TESTSTART]{
|
||||||
SetFG(Color_Blue)
|
song=loadSong("test.flac")
|
||||||
write("This is blue ")
|
setFG(Color_Blue)
|
||||||
SetFG(Color_Red)
|
|
||||||
print("This is red")
|
|
||||||
ResetColor()
|
|
||||||
"Hello (Press Enter)"
|
"Hello (Press Enter)"
|
||||||
print("PLAY SONG (1)")
|
-- print("PLAY SONG (1)")
|
||||||
print("MESSAGE (2)")
|
-- print("MESSAGE (2)")
|
||||||
print("An Adventure (3)")
|
-- print("An Adventure (3)")
|
||||||
print("QUIT (4)")
|
-- print("QUIT (4)")
|
||||||
|
fancy("left","PLAY SONG (1),MESSAGE (2),An Adventure (3),QUIT (4)")
|
||||||
::choice::
|
::choice::
|
||||||
write("Choose: ")
|
write("Choose: ")
|
||||||
choice=GetInput()
|
choice=getInput()
|
||||||
if choice=="1" then JUMP("SONG")|SKIP(0)
|
if choice=="1" then JUMP("SONG")|SKIP(0)
|
||||||
if choice=="2" then JUMP("YO")|SKIP(0)
|
if choice=="2" then JUMP("YO")|SKIP(0)
|
||||||
if choice=="4" then QUIT()|SKIP(0)
|
if choice=="4" then QUIT()|SKIP(0)
|
||||||
if choice=="3" then SKIP(2)|SKIP(0)
|
if choice=="3" then SKIP(2)|SKIP(0)
|
||||||
GOTO("choice")
|
GOTO("choice")
|
||||||
"We are here now! Time for some fun..."
|
"We are here now! Time for some fun..."
|
||||||
|
::name::
|
||||||
write("Please enter your name: ")
|
write("Please enter your name: ")
|
||||||
name=GetInput()
|
name=getInput()
|
||||||
setCC()
|
|
||||||
if name=="" then SKIP(-4)|SKIP(0)
|
|
||||||
ClearLine()
|
ClearLine()
|
||||||
|
setCC()
|
||||||
|
if name=="" then GOTO("name")|SKIP(0)
|
||||||
print("So your name is $name$ huh...")
|
print("So your name is $name$ huh...")
|
||||||
"I won't judge haha"
|
"I won't judge haha"
|
||||||
"Anyway let's get controls for that song"
|
"Anyway let's get controls for that song"
|
||||||
@ -34,11 +33,11 @@ ENTRY TESTSTART
|
|||||||
print("Quit (q)")
|
print("Quit (q)")
|
||||||
::control::
|
::control::
|
||||||
write("Choose: ")
|
write("Choose: ")
|
||||||
choice=GetInput()
|
choice=getInput()
|
||||||
if choice=="s" then STOP(song)|SKIP(0)
|
if choice=="s" then STOP(song)|SKIP(0)
|
||||||
if choice=="t" then JUMP("PLAYS")|SKIP(0)
|
if choice=="t" then JUMP("PLAYS")|SKIP(0)
|
||||||
if choice=="a" then PAUSE(song)|SKIP(0)
|
if choice=="a" then pauseSong(song)|SKIP(0)
|
||||||
if choice=="r" then RESUME(song)|SKIP(0)
|
if choice=="r" then resumeSong(song)|SKIP(0)
|
||||||
if choice=="q" then QUIT()|SKIP(0)
|
if choice=="q" then QUIT()|SKIP(0)
|
||||||
GOTO("control")
|
GOTO("control")
|
||||||
}
|
}
|
||||||
@ -47,12 +46,13 @@ ENTRY TESTSTART
|
|||||||
setCC()
|
setCC()
|
||||||
}
|
}
|
||||||
[PLAYS]{
|
[PLAYS]{
|
||||||
PAUSE(song)
|
pauseSong(song)
|
||||||
song=PLAY("test.flac")
|
song=loadSong("test.flac")
|
||||||
|
playSong(song)
|
||||||
GOTO("control")
|
GOTO("control")
|
||||||
}
|
}
|
||||||
[SONG]{
|
[SONG]{
|
||||||
song=PLAY("test.flac")
|
playSong(song)
|
||||||
GOTO("choice")
|
GOTO("choice")
|
||||||
}
|
}
|
||||||
[YO]{
|
[YO]{
|
||||||
|
|||||||
@ -6,10 +6,15 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using CSCore;
|
||||||
|
using CSCore.Codecs;
|
||||||
|
using CSCore.SoundOut;
|
||||||
using parseManagerCS;
|
using parseManagerCS;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using FancyPrintCS;
|
||||||
namespace parseManagerCS
|
namespace parseManagerCS
|
||||||
{
|
{
|
||||||
/// The parseManager is an Advance Config Script
|
/// The parseManager is an Advance Config Script
|
||||||
@ -156,7 +161,8 @@ namespace parseManagerCS
|
|||||||
// foreach (Match m in Regex.Matches(data, @"USING ([a-zA-Z0-9_\./]+)")) {
|
// foreach (Match m in Regex.Matches(data, @"USING ([a-zA-Z0-9_\./]+)")) {
|
||||||
// m.Groups[1].ToString();
|
// m.Groups[1].ToString();
|
||||||
// }
|
// }
|
||||||
var match = Regex.Matches(data, @"\[(.+)\][\r\n]*?\{([^\0]+?)\}");
|
data = data + "\n";
|
||||||
|
var match = Regex.Matches(data, "\\[(.+)\\][\r\n]*?\\{([^\0]+?)\\}\r?\n");
|
||||||
var count = 0;
|
var count = 0;
|
||||||
foreach (Match m in match) {
|
foreach (Match m in match) {
|
||||||
string Blck = m.Groups[1].ToString();
|
string Blck = m.Groups[1].ToString();
|
||||||
@ -307,6 +313,9 @@ namespace parseManagerCS
|
|||||||
}
|
}
|
||||||
public ENV GetENV()
|
public ENV GetENV()
|
||||||
{
|
{
|
||||||
|
if (_defualtENV == null) {
|
||||||
|
return _mainENV;
|
||||||
|
}
|
||||||
return _defualtENV;
|
return _defualtENV;
|
||||||
}
|
}
|
||||||
public ENV GetDENV()
|
public ENV GetDENV()
|
||||||
@ -535,7 +544,7 @@ namespace parseManagerCS
|
|||||||
bool boo;
|
bool boo;
|
||||||
double ex;
|
double ex;
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
if (!v[i].StartsWith("["))
|
if (!v[i].StartsWith("[") && !v[i].StartsWith("\""))
|
||||||
ex = evaluater.Evaluate(v[i]);
|
ex = evaluater.Evaluate(v[i]);
|
||||||
else
|
else
|
||||||
ex = double.NaN;
|
ex = double.NaN;
|
||||||
@ -671,9 +680,9 @@ namespace parseManagerCS
|
|||||||
var m = Regex.Match(_type, @"([a-zA-Z0-9_]+)");
|
var m = Regex.Match(_type, @"([a-zA-Z0-9_]+)");
|
||||||
_pureType = m.Groups[1].ToString();
|
_pureType = m.Groups[1].ToString();
|
||||||
var tCont = Regex.Replace(cont, @"\-\-\[\[[\S\s]+\]\]", "", RegexOptions.Multiline);
|
var tCont = Regex.Replace(cont, @"\-\-\[\[[\S\s]+\]\]", "", RegexOptions.Multiline);
|
||||||
tCont = Regex.Replace(tCont, @"\-\-.+\r\n", "", RegexOptions.Multiline);
|
|
||||||
tCont = Regex.Replace(tCont, @"\-\-.+\n", "", RegexOptions.Multiline);
|
|
||||||
tCont = Regex.Replace(tCont, @"\t", "", RegexOptions.Multiline);
|
tCont = Regex.Replace(tCont, @"\t", "", RegexOptions.Multiline);
|
||||||
|
tCont = Regex.Replace(tCont, @"^\-\-.+\r\n", "", RegexOptions.Multiline);
|
||||||
|
tCont = Regex.Replace(tCont, @"^\-\-.+\n", "", RegexOptions.Multiline);
|
||||||
tCont = Regex.Replace(tCont, @"\n\n", "", RegexOptions.Multiline);
|
tCont = Regex.Replace(tCont, @"\n\n", "", RegexOptions.Multiline);
|
||||||
tCont = Regex.Replace(tCont, @"\r\n\r\n", "", RegexOptions.Multiline);
|
tCont = Regex.Replace(tCont, @"\r\n\r\n", "", RegexOptions.Multiline);
|
||||||
tCont = Regex.Replace(tCont, @"\-\-\[\[[\S\s]+\]\]", "", RegexOptions.Multiline);
|
tCont = Regex.Replace(tCont, @"\-\-\[\[[\S\s]+\]\]", "", RegexOptions.Multiline);
|
||||||
@ -1206,6 +1215,7 @@ namespace parseManagerCS
|
|||||||
}
|
}
|
||||||
public class standardDefine
|
public class standardDefine
|
||||||
{
|
{
|
||||||
|
double count;
|
||||||
Random rnd = new Random();
|
Random rnd = new Random();
|
||||||
public void newThread(parseManager PM, string Block)
|
public void newThread(parseManager PM, string Block)
|
||||||
{
|
{
|
||||||
@ -1248,10 +1258,6 @@ public class standardDefine
|
|||||||
env["__DefualtENV"] = PM.GetENV();
|
env["__DefualtENV"] = PM.GetENV();
|
||||||
GLOBALS.WriteToBinaryFile("savedata.dat", env);
|
GLOBALS.WriteToBinaryFile("savedata.dat", env);
|
||||||
}
|
}
|
||||||
public void save(parseManager PM)
|
|
||||||
{
|
|
||||||
SAVE(PM);
|
|
||||||
}
|
|
||||||
public bool LOAD(parseManager PM)
|
public bool LOAD(parseManager PM)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
@ -1268,49 +1274,41 @@ public class standardDefine
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void load(parseManager PM)
|
|
||||||
{
|
|
||||||
LOAD(PM);
|
|
||||||
}
|
|
||||||
public void TRACEBACK(parseManager PM)
|
public void TRACEBACK(parseManager PM)
|
||||||
{
|
{
|
||||||
ENV env = PM.Pop();
|
ENV env = PM.Pop();
|
||||||
PM.SetBlock((string)env[0]);
|
PM.SetBlock((string)env[0]);
|
||||||
var c = PM.GetCurrentChunk();
|
var c = PM.GetCurrentChunk();
|
||||||
c.SetPos((int)env[1]);
|
c.SetPos((int)env[1]);
|
||||||
SetENV(PM, (ENV)env[3]);
|
setENV(PM, (ENV)env[3]);
|
||||||
}
|
}
|
||||||
public void EXIT(parseManager PM)
|
public void EXIT(parseManager PM)
|
||||||
{
|
{
|
||||||
PM.Deactivate();
|
PM.Deactivate();
|
||||||
}
|
}
|
||||||
public void exit(parseManager PM)
|
|
||||||
{
|
|
||||||
EXIT(PM);
|
|
||||||
}
|
|
||||||
public void QUIT(parseManager PM)
|
public void QUIT(parseManager PM)
|
||||||
{
|
{
|
||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
public void SetENV(parseManager PM, ENV env)
|
public void setENV(parseManager PM, ENV env)
|
||||||
{
|
{
|
||||||
PM.SetENV(env);
|
PM.SetENV(env);
|
||||||
}
|
}
|
||||||
public ENV GetENV(parseManager PM)
|
public ENV getENV(parseManager PM)
|
||||||
{
|
{
|
||||||
return PM.GetENV();
|
return PM.GetENV();
|
||||||
}
|
}
|
||||||
public ENV GetDefualtENV(parseManager PM)
|
public ENV getDefualtENV(parseManager PM)
|
||||||
{
|
{
|
||||||
return PM.GetDENV();
|
return PM.GetDENV();
|
||||||
}
|
}
|
||||||
public ENV CreateENV(parseManager PM)
|
public ENV createENV(parseManager PM)
|
||||||
{
|
{
|
||||||
var temp = new ENV();
|
var temp = new ENV();
|
||||||
temp.SetParent(PM.GetENV());
|
temp.SetParent(PM.GetENV());
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
public string GetInput(parseManager PM)
|
public string getInput(parseManager PM)
|
||||||
{
|
{
|
||||||
return Console.ReadLine();
|
return Console.ReadLine();
|
||||||
}
|
}
|
||||||
@ -1324,15 +1322,15 @@ public class standardDefine
|
|||||||
Console.Write(" ");
|
Console.Write(" ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public void SetBG(parseManager PM, ConsoleColor BG)
|
public void setBG(parseManager PM, ConsoleColor BG)
|
||||||
{
|
{
|
||||||
Console.BackgroundColor = BG;
|
Console.BackgroundColor = BG;
|
||||||
}
|
}
|
||||||
public void SetFG(parseManager PM, ConsoleColor FG)
|
public void setFG(parseManager PM, ConsoleColor FG)
|
||||||
{
|
{
|
||||||
Console.ForegroundColor = FG;
|
Console.ForegroundColor = FG;
|
||||||
}
|
}
|
||||||
public void ResetColor(parseManager PM)
|
public void resetColor(parseManager PM)
|
||||||
{
|
{
|
||||||
Console.ResetColor();
|
Console.ResetColor();
|
||||||
}
|
}
|
||||||
@ -1356,7 +1354,7 @@ public class standardDefine
|
|||||||
PM.PushError("Unable to GOTO a non existing label: " + label + "!");
|
PM.PushError("Unable to GOTO a non existing label: " + label + "!");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
public double LEN(parseManager PM, object o)
|
public double len(parseManager PM, object o)
|
||||||
{
|
{
|
||||||
string type = o.GetType().ToString();
|
string type = o.GetType().ToString();
|
||||||
if (type.Contains("String")) {
|
if (type.Contains("String")) {
|
||||||
@ -1367,30 +1365,18 @@ public class standardDefine
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
public double len(parseManager PM, object o)
|
|
||||||
{
|
|
||||||
return LEN(PM, o);
|
|
||||||
}
|
|
||||||
public void JUMP(parseManager PM, string block)
|
public void JUMP(parseManager PM, string block)
|
||||||
{
|
{
|
||||||
var c = PM.GetCurrentChunk();
|
var c = PM.GetCurrentChunk();
|
||||||
c.ResetPos();
|
c.ResetPos();
|
||||||
PM.SetBlock(block);
|
PM.SetBlock(block);
|
||||||
}
|
}
|
||||||
public void jump(parseManager PM, string block)
|
|
||||||
{
|
|
||||||
JUMP(PM, block);
|
|
||||||
}
|
|
||||||
public void SKIP(parseManager PM, double n)
|
public void SKIP(parseManager PM, double n)
|
||||||
{
|
{
|
||||||
var c = PM.GetCurrentChunk();
|
var c = PM.GetCurrentChunk();
|
||||||
var pos = c.GetPos();
|
var pos = c.GetPos();
|
||||||
c.SetPos(pos + (int)n);
|
c.SetPos(pos + (int)n);
|
||||||
}
|
}
|
||||||
public void skip(parseManager PM, double n)
|
|
||||||
{
|
|
||||||
SKIP(PM, n);
|
|
||||||
}
|
|
||||||
public double tonumber(parseManager PM, string strn)
|
public double tonumber(parseManager PM, string strn)
|
||||||
{
|
{
|
||||||
double d;
|
double d;
|
||||||
@ -1402,8 +1388,12 @@ public class standardDefine
|
|||||||
}
|
}
|
||||||
public void sleep(parseManager PM, double n)
|
public void sleep(parseManager PM, double n)
|
||||||
{
|
{
|
||||||
int i = (int)n * 1000;
|
Thread.Sleep((int)n);
|
||||||
Thread.Sleep(i);
|
}
|
||||||
|
public void setVar(parseManager PM, string var, object value)
|
||||||
|
{
|
||||||
|
var env = PM.GetDENV();
|
||||||
|
env[var] = value;
|
||||||
}
|
}
|
||||||
public double ADD(parseManager PM, double a, double b)
|
public double ADD(parseManager PM, double a, double b)
|
||||||
{
|
{
|
||||||
@ -1449,8 +1439,83 @@ public class standardDefine
|
|||||||
{
|
{
|
||||||
return Math.Round(num, (int)n);
|
return Math.Round(num, (int)n);
|
||||||
}
|
}
|
||||||
|
public void clear(parseManager PM)
|
||||||
|
{
|
||||||
|
Console.Clear();
|
||||||
|
}
|
||||||
public void write(parseManager PM, object o)
|
public void write(parseManager PM, object o)
|
||||||
{
|
{
|
||||||
Console.Write(o);
|
Console.Write(o);
|
||||||
}
|
}
|
||||||
|
public void backspace(parseManager PM)
|
||||||
|
{
|
||||||
|
Console.Write("\b");
|
||||||
|
}
|
||||||
|
public void beep(parseManager PM)
|
||||||
|
{
|
||||||
|
Console.Beep();
|
||||||
|
}
|
||||||
|
public void fancy(parseManager PM, string form, string msg)
|
||||||
|
{
|
||||||
|
Fancy.SetForm(form);
|
||||||
|
Fancy.Print(msg);
|
||||||
|
}
|
||||||
|
ISoundOut GetSoundOut()
|
||||||
|
{
|
||||||
|
if (WasapiOut.IsSupportedOnCurrentPlatform)
|
||||||
|
return new WasapiOut();
|
||||||
|
else
|
||||||
|
return new DirectSoundOut();
|
||||||
|
}
|
||||||
|
IWaveSource GetSoundSource(string path)
|
||||||
|
{
|
||||||
|
return CodecFactory.Instance.GetCodec(path);
|
||||||
|
}
|
||||||
|
public void _load()
|
||||||
|
{
|
||||||
|
string path = (string)GLOBALS.GetData("__MUSIC");
|
||||||
|
double id = (double)GLOBALS.GetData("__MUSICH");
|
||||||
|
using (IWaveSource soundSource = GetSoundSource(path)) {
|
||||||
|
using (ISoundOut soundOut = GetSoundOut()) {
|
||||||
|
soundOut.Initialize(soundSource);
|
||||||
|
GLOBALS.AddData("__MUSICH" + id, soundOut);
|
||||||
|
while (true) {
|
||||||
|
Thread.Sleep(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void stopSong(parseManager PM, double id)
|
||||||
|
{
|
||||||
|
var sound = (ISoundOut)GLOBALS.GetData("__MUSICH" + id);
|
||||||
|
sound.Stop();
|
||||||
|
}
|
||||||
|
public void playSong(parseManager PM, double id)
|
||||||
|
{
|
||||||
|
var sound = (ISoundOut)GLOBALS.GetData("__MUSICH" + id);
|
||||||
|
sound.Play();
|
||||||
|
}
|
||||||
|
public void resumeSong(parseManager PM, double id)
|
||||||
|
{
|
||||||
|
var sound = (ISoundOut)GLOBALS.GetData("__MUSICH" + id);
|
||||||
|
sound.Resume();
|
||||||
|
}
|
||||||
|
public void setSongVolume(parseManager PM, double id, double vol)
|
||||||
|
{
|
||||||
|
var sound = (ISoundOut)GLOBALS.GetData("__MUSICH" + id);
|
||||||
|
sound.Volume = (float)vol;
|
||||||
|
}
|
||||||
|
public void pauseSong(parseManager PM, double id)
|
||||||
|
{
|
||||||
|
var sound = (ISoundOut)GLOBALS.GetData("__MUSICH" + id);
|
||||||
|
sound.Pause();
|
||||||
|
}
|
||||||
|
public double loadSong(parseManager PM, string filepath)
|
||||||
|
{
|
||||||
|
GLOBALS.AddData("__MUSIC", filepath);
|
||||||
|
GLOBALS.AddData("__MUSICH", count++);
|
||||||
|
var oThread = new Thread(new ThreadStart(_load));
|
||||||
|
oThread.Start();
|
||||||
|
return count - 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -37,6 +37,9 @@
|
|||||||
<Reference Include="Microsoft.CSharp">
|
<Reference Include="Microsoft.CSharp">
|
||||||
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
<RequiredTargetFramework>4.0</RequiredTargetFramework>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="PresentationCore">
|
||||||
|
<RequiredTargetFramework>3.0</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Core">
|
<Reference Include="System.Core">
|
||||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
@ -45,12 +48,19 @@
|
|||||||
<Reference Include="System.Data.DataSetExtensions">
|
<Reference Include="System.Data.DataSetExtensions">
|
||||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="System.Windows.Presentation">
|
||||||
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
<Reference Include="System.Xml.Linq">
|
<Reference Include="System.Xml.Linq">
|
||||||
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
<RequiredTargetFramework>3.5</RequiredTargetFramework>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="WindowsBase">
|
||||||
|
<RequiredTargetFramework>3.0</RequiredTargetFramework>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="Fancy.cs" />
|
||||||
<Compile Include="parseManager.cs" />
|
<Compile Include="parseManager.cs" />
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user