예제 #1
0
        public void Run( params string [] args )
        {
            if ( args.Length < 4 || args.Length > 2 )
            {
                Console.WriteLine ( "PACKING USECASE:" );
                Console.WriteLine ( "  lemon.exe -scr <Output> <Script Language Type> <Directory>" );
                Console.WriteLine ( "APPEND USECASE:" );
                Console.WriteLine ( "  lemon.exe -scr <Destination> <Script filename>" );
                Console.WriteLine ( "FILEMOVE USECASE:" );
                Console.WriteLine ( "  lemon.exe -scr <Destination> <Packed filename> <UpDown State> <Count>" );
                Console.WriteLine ( "    Up Down State - up: Up, dn: Down" );
            }
            else if ( args.Length == 3 )
            {
                using ( Stream stream = new FileStream ( args [ 0 ], FileMode.Create ) )
                {
                    BinaryWriter writer = new BinaryWriter ( stream );
                    writer.Write ( Encoding.UTF8.GetBytes ( "WNSC" ) );
                    writer.Write ( ( uint ) ( ScriptType ) Enum.Parse ( typeof ( ScriptType ), args [ 1 ] ) );

                    string [] filenames = Directory.GetFiles ( args [ 2 ], "*", SearchOption.AllDirectories );
                    string dirFullname = Path.GetDirectoryName ( filenames [ 0 ] );
                    foreach ( string filename in filenames )
                    {
                        writer.Write ( Encoding.UTF8.GetBytes ( "SCRT" ) );
                        using ( DeflateStream ds = new DeflateStream ( stream, CompressionMode.Compress, false ) )
                        {
                            BinaryWriter innerWriter = new BinaryWriter ( ds );
                            innerWriter.Write ( Encoding.UTF8.GetBytes ( filename.Remove ( 0, dirFullname.Length + 1 ).PadLeft ( 32 ) ) );
                            innerWriter.Write ( File.ReadAllText ( filename ) );
                            Console.WriteLine ( "Processed: {0}", filename );
                        }
                    }
                    writer.Write ( Encoding.UTF8.GetBytes ( "NONE" ) );
                }
            }
            else if ( args.Length == 2 )
            {
                using ( Stream stream = new FileStream ( args [ 0 ], FileMode.Open ) )
                {
                    BinaryWriter writer = new BinaryWriter ( stream );
                    stream.Position = stream.Length - 4;
                    writer.Write ( Encoding.UTF8.GetBytes ( "SCRT" ) );
                    using ( DeflateStream ds = new DeflateStream ( stream, CompressionMode.Compress, false ) )
                    {
                        string filename = args [ 1 ];
                        BinaryWriter innerWriter = new BinaryWriter ( ds );
                        innerWriter.Write ( Encoding.UTF8.GetBytes ( filename.PadLeft ( 32 ) ) );
                        innerWriter.Write ( File.ReadAllText ( filename ) );
                        Console.WriteLine ( "Processed: {0}", filename );
                    }
                    writer.Write ( Encoding.UTF8.GetBytes ( "NONE" ) );
                }
            }
            else if ( args.Length == 4 )
            {
                using ( Stream stream = new FileStream ( args [ 0 ], FileMode.Open ) )
                {
                    ScriptTable scriptTable = new ScriptTable ( stream );
                    stream.Position = 8;

                    BinaryWriter writer = new BinaryWriter ( stream );
                    foreach ( KeyValuePair<string, string> pair in scriptTable )
                    {
                        writer.Write ( Encoding.UTF8.GetBytes ( "SCRT" ) );
                        using ( DeflateStream ds = new DeflateStream ( stream, CompressionMode.Compress, false ) )
                        {
                            BinaryWriter innerWriter = new BinaryWriter ( ds );
                            innerWriter.Write ( Encoding.UTF8.GetBytes ( pair.Key.PadLeft ( 32 ) ) );
                            innerWriter.Write ( pair.Value );
                            Console.WriteLine ( "Processed: {0}", pair.Key );
                        }
                    }
                }
            }
        }
예제 #2
0
        public GlyphSetPosition(TtfTypeface typeface, string lang)
        {
            this.Lang     = lang;
            this.typeface = typeface;
            //check if this lang has
            this.gposTable = typeface.GPOSTable;

            if (gposTable == null)
            {
                return;
            }

            ScriptTable scriptTable = gposTable.ScriptList[lang];

            //---------
            if (scriptTable == null)
            {
                return;
            }                                      // early exit if no lookup tables
                                                   //---------

            ScriptTable.LangSysTable defaultLang = scriptTable.defaultLang;
            if (defaultLang == null)
            {
                return;
            }                                      // early exit if no default language

            if (defaultLang.HasRequireFeature)
            {
            }
            //other feature
            if (defaultLang.featureIndexList != null)
            {
                //get features
                var features = new List <FeatureList.FeatureTable>();
                for (int i = 0; i < defaultLang.featureIndexList.Length; ++i)
                {
                    FeatureList.FeatureTable feature = gposTable.FeatureList.featureTables[defaultLang.featureIndexList[i]];

                    switch (feature.TagName)
                    {
                    case "mark":    //mark=> mark to base
                    case "mkmk":    //mkmk => mark to mask
                        //current version we implement this 2 features
                        features.Add(feature);
                        break;

                    case "kern":
                        //test with Candara font
                        features.Add(feature);
                        //If palt is activated, there is no requirement that kern must also be activated.
                        //If kern is activated, palt must also be activated if it exists.
                        //https://www.microsoft.com/typography/OTSpec/features_pt.htm#palt
                        break;

                    case "palt":

                        break;

                    default:
                        break;
                    }
                }

                //-----------------------

                lookupTables = new List <GPOS.LookupTable>();
                int j = features.Count;
                for (int i = 0; i < j; ++i)
                {
                    FeatureList.FeatureTable feature = features[i];
                    foreach (ushort lookupIndex in feature.LookupListIndices)
                    {
                        lookupTables.Add(gposTable.LookupList[lookupIndex]);
                    }
                }
            }
        }
 public ScriptTableDetails(Language language, string featureName, ScriptTable scriptTable)
 {
     this.language    = language;
     this.featureName = featureName;
     this.scriptTable = scriptTable;
 }
예제 #4
0
 public TableKPairs(ScriptTable obj)
 {
     m_Enumerator = obj.GetIterator();
 }
예제 #5
0
 void OnCall(ScriptTable table)
 {
     Call((string)table.GetValue("Func").ObjectValue, table.GetValue("Args"));
 }
예제 #6
0
        static void Main(string[] args)
        {
            Console.WriteLine("Starting server.");

            StartTime = DateTime.Now.ToUniversalTime();
            LoadDatabase();

            /*
             * Task.Factory.StartNew(() =>
             * {
             *  while (true)
             *  {
             *      try
             *      {
             *          IRCBot bottymcbotface = new IRCBot();
             *          bottymcbotface.Start("irc.frenetic.xyz", 6667, "#script-tracker");
             *      }
             *      catch (Exception ex)
             *      {
             *          Console.WriteLine(ex.ToString());
             *      }
             *  }
             * });
             */
            Task.Factory.StartNew(() =>
            {
                while (true)
                {
                    try
                    {
                        IRCBot bottymcbotface = new IRCBot();
                        bottymcbotface.Start("irc.esper.net", 6667, "#denizen-dev");
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                }
            });
            Task.Factory.StartNew(() =>
            {
                while (true)
                {
                    Thread.Sleep(1000 * 60 * 10);
                    try
                    {
                        int lastID    = ScriptTable.Last().ID + 1;
                        string result = client.GetStringAsync("http://one.denizenscript.com/denizen/repo/entry/" + lastID).Result;
                        if (result == null)
                        {
                            continue;
                        }
                        string name = result.After("<title>").Before(" by ");
                        if ((name == "") || (name.StartsWith("Invalid paste number")))
                        {
                            continue;
                        }
                        LoadDatabase();
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                }
            });

            var listener = new HttpListener();

            //listener.Prefixes.Add("http://localhost:8099/");
            listener.Prefixes.Add("http://*:8099/");
            //listener.Prefixes.Add("http://127.0.0.1:10123/");

            listener.Start();

            while (true)
            {
                HttpListenerContext context = null;
                try
                {
                    context = listener.GetContext();
                    context.Response.StatusCode  = 200;
                    context.Response.ContentType = "text/html";
                    string page = context.Request.Url.LocalPath.Before("?");
                    switch (page)
                    {
                    case "/tracker":
                        HandleTrackerInput(context);
                        break;

                    case "/scripts":
                        webPages.getScriptPage(context);
                        break;

                    case "/popular":
                        webPages.getPopularPage(context);
                        break;

                    case "/howto":
                        webPages.getHowToPage(context);
                        break;

                    case "/graph":
                        context.Response.ContentType = "image/png";
                        webPages.getGraphImage(context);
                        break;

                    case "/populargraph":
                        context.Response.ContentType = "image/png";
                        webPages.getPopularGraph(context);
                        break;
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    if (context != null)
                    {
                        byte[] data = Encoding.UTF8.GetBytes("FAILURE! Unable to process your request."); // better 404
                        context.Response.OutputStream.Write(data, 0, data.Length);
                    }
                }
                finally
                {
                    if (context != null)
                    {
                        context.Response.OutputStream.Close();
                    }
                }
            }
        }
예제 #7
0
 public TablePairs(Script script, ScriptTable obj)
 {
     m_Script     = script;
     m_Enumerator = obj.GetIterator();
 }
예제 #8
0
 public static void RunAll( this IScriptEngine scriptEngine, ScriptTable table )
 {
     if ( scriptEngine.ScriptType != table.ScriptType ) throw new ScriptLanguageMismatchException ();
     foreach ( KeyValuePair<string, string> pair in table )
         scriptEngine.Run ( pair.Value );
 }
예제 #9
0
 public void SetTable(ScriptTable table)
 {
     m_IsStaticFunction    = false;
     m_stackObject["this"] = table;
     m_stackObject["self"] = table;
 }
예제 #10
0
        public GlyphSubStitution(Typeface typeface, string lang)
        {
            this.EnableLigation = true;//enable by default
            this.Lang           = lang;
            this.typeface       = typeface;
            //check if this lang has
            gsubTable = typeface.GSUBTable;
            ScriptTable scriptTable = gsubTable.ScriptList.FindScriptTable(lang);

            //---------
            if (scriptTable == null)
            {
                return;
            }                                      //early exit if no lookup tables

            //---------
            ScriptTable.LangSysTable selectedLang = null;
            if (scriptTable.langSysTables != null && scriptTable.langSysTables.Length > 0)
            {
                //TODO: review here
                selectedLang = scriptTable.langSysTables[0];
            }
            else
            {
                selectedLang = scriptTable.defaultLang;
            }

            if (selectedLang.HasRequireFeature)
            {
                //TODO: review here
            }
            //other feature
            if (selectedLang.featureIndexList != null)
            {
                //get features
                var features = new List <FeatureList.FeatureTable>();
                for (int i = 0; i < selectedLang.featureIndexList.Length; ++i)
                {
                    FeatureList.FeatureTable feature = gsubTable.FeatureList.featureTables[selectedLang.featureIndexList[i]];
                    switch (feature.TagName)
                    {
                    case "ccmp":     //glyph composition/decomposition
                                     //this version we implement ccmp
                        features.Add(feature);
                        break;

                    case "liga":
                        //Standard Ligatures --enable by default
                        features.Add(feature);
                        break;
                    }
                }
                //-----------------------
                lookupTables = new List <GSUB.LookupTable>();
                int j = features.Count;
                for (int i = 0; i < j; ++i)
                {
                    FeatureList.FeatureTable feature = features[i];
                    ushort[] lookupListIndices       = feature.LookupListIndice;
                    foreach (ushort lookupIndex in lookupListIndices)
                    {
                        GSUB.LookupTable lktable = gsubTable.GetLookupTable(lookupIndex);
                        lktable.ForUseWithFeatureId = feature.TagName;
                        lookupTables.Add(gsubTable.GetLookupTable(lookupIndex));
                    }
                }
            }
        }
예제 #11
0
 public static void Run( this IScriptEngine scriptEngine, ScriptTable table, string name )
 {
     if ( scriptEngine.ScriptType != table.ScriptType ) throw new ScriptLanguageMismatchException ();
     scriptEngine.Run ( table [ name ] );
 }
예제 #12
0
        public GlyphSetPosition(Typeface typeface, string lang)
        {
            this.Lang     = lang;
            this.typeface = typeface;
            //check if this lang has
            this.gposTable = typeface.GPOSTable;

            if (gposTable == null)
            {
                return;
            }

            ScriptTable scriptTable = gposTable.ScriptList.FindScriptTable(lang);

            //---------
            if (scriptTable == null)
            {
                return;
            }                                      //early exit if no lookup tables
                                                   //---------

            ScriptTable.LangSysTable defaultLang = scriptTable.defaultLang;

            if (defaultLang.HasRequireFeature)
            {
            }
            //other feature
            if (defaultLang.featureIndexList != null)
            {
                //get features
                var features = new List <FeatureList.FeatureTable>();
                for (int i = 0; i < defaultLang.featureIndexList.Length; ++i)
                {
                    FeatureList.FeatureTable feature = gposTable.FeatureList.featureTables[defaultLang.featureIndexList[i]];

                    switch (feature.TagName)
                    {
                    case "mark":    //mark=> mark to base
                    case "mkmk":    //mkmk => mark to mask

                        //current version we implement this 2 features
                        features.Add(feature);
                        break;

                    default:
                    {
                    }
                    break;
                    }
                }

                //-----------------------

                lookupTables = new List <GPOS.LookupTable>();
                int j = features.Count;
                for (int i = 0; i < j; ++i)
                {
                    FeatureList.FeatureTable feature = features[i];
                    ushort[] lookupListIndices       = feature.LookupListIndice;
                    foreach (ushort lookupIndex in lookupListIndices)
                    {
                        lookupTables.Add(gposTable.GetLookupTable(lookupIndex));
                    }
                }
            }
        }
예제 #13
0
 public void SaveScripts(ScriptTable scripts, IStream stream)
 {
     throw new NotImplementedException();
 }
예제 #14
0
        public GlyphSetPosition(Typeface typeface, uint scriptTag, uint langTag)
        {
            this.ScriptTag = scriptTag; //script tag
            this.LangTag   = langTag;   //lang tag


            //check if this lang has
            _gposTable = typeface.GPOSTable;

            if (_gposTable == null)
            {
                return;
            }

            ScriptTable scriptTable = _gposTable.ScriptList[scriptTag];

            if (scriptTable == null)
            {
                return;
            }                                      // early exit if no lookup tables



            ScriptTable.LangSysTable selectedLang = scriptTable.defaultLang;
            if (selectedLang == null)
            {
                return;                                            //no default
            }
            if (LangTag != 0 && scriptTable.langSysTables != null) //use default
            {
                //find matching lang
                for (int i = 0; i < scriptTable.langSysTables.Length; ++i)
                {
                    if (scriptTable.langSysTables[i].langSysTagIden == LangTag)
                    {
                        //found
                        selectedLang = scriptTable.langSysTables[i];
                        break;
                    }
                }
            }

#if DEBUG
            dbugTypeface = typeface;
            if (selectedLang.HasRequireFeature)
            {
                System.Diagnostics.Debugger.Break();
            }
#endif
            //other feature
            if (selectedLang.featureIndexList == null)
            {
                return;
            }                                                     // early exit

            //---------
            //get features
            _lookupTables = new List <GPOS.LookupTable>();

            for (int i = 0; i < selectedLang.featureIndexList.Length; ++i)
            {
                FeatureList.FeatureTable feature = _gposTable.FeatureList.featureTables[selectedLang.featureIndexList[i]];
                bool includeThisFeature          = false;
                switch (feature.TagName)
                {
                case "mark":    //mark=> mark to base
                case "mkmk":    //mkmk => mark to mask
                                //current version we implement this 2 features
                    includeThisFeature = true;
                    break;

                case "kern":
                    //test with Candara font
                    includeThisFeature = true;
                    //If palt is activated, there is no requirement that kern must also be activated.
                    //If kern is activated, palt must also be activated if it exists.
                    //https://www.microsoft.com/typography/OTSpec/features_pt.htm#palt
                    break;
                //case "palt":
                //    break;

                case "abvm":
                case "blwm":
                case "dist":
                    includeThisFeature = true;
                    break;

                default:
                    System.Diagnostics.Debug.WriteLine("gpos_skip_tag:" + feature.TagName);
                    break;
                }

                if (includeThisFeature)
                {
                    foreach (ushort lookupIndex in feature.LookupListIndices)
                    {
                        _lookupTables.Add(_gposTable.LookupList[lookupIndex]);
                    }
                }
            }
        }
예제 #15
0
        /// <summary>
        /// 초기화
        /// </summary>
        public void Initialize()
        {
            try
            {
                m_engine		= new Script();						// 엔진 인스턴스 초기화
                m_engine.Options.DebugPrint	= (s) =>				// lua의 print 아웃풋 설정
                    {
                        Debug.Log("[LUA Print] " + s);
                    };

                m_engine.DoFile(c_entryScript);						// 시작 스크립트 실행

                // Lua 테이블 가져오기
                m_tablePlayer			= LoadSingleScriptTable(c_field_playerScript);
                m_tableEmperor			= LoadSingleScriptTable(c_field_emperorScript);
                m_tableIndivdualList	= LoadScriptTableArray(c_field_individualScripts);
                m_tableFactionList		= LoadScriptTableArray(c_field_factionScripts);

                m_tableActivityList		= LoadScriptTableArray(c_field_activityScripts);
                m_tableItemList			= LoadScriptTableArray(c_field_itemScripts);
                m_tableEventList		= LoadScriptTableArray(c_field_eventScripts);

                m_gameTable				= DynValue.NewTable(m_engine).Table;	// 게임 오브젝트 테이블
                m_engine.Globals["Game"]	= m_gameTable;
            }

            catch(ScriptRuntimeException ex)
            {
                HandleScriptError(ex);
            }
        }
예제 #16
0
        //解析一个网络协议
        // public static ScriptTable Deserialize(Script script, byte[] data, string layoutTableName) {
        //     return Read(script, new ScorpioReader(data), null, "", layoutTableName, true);
        // }

        /// <summary>
        /// 脚本 读取excel文件数据内容
        /// </summary>
        /// <param name="script"></param>
        /// <param name="fileName"></param>
        /// <param name="reader"></param>
        /// <param name="dataArray"></param>
        /// <param name="layoutTableName"></param>
        /// <param name="keyName"></param>
        /// <param name="MD5"></param>
        /// <returns></returns>
        public static ScriptTable ReadDatas(Script script, string fileName, IScorpioReader reader, ScriptTable dataArray, string layoutTableName, string keyName, string MD5)
        {
            var iRow = TableUtil.ReadHead(reader, fileName, MD5);

            for (var i = 0; i < iRow; ++i)
            {
                var data = Read(script, reader, layoutTableName, false);
                data.SetValue("ID", data.GetValue(keyName));
                var key = data.GetValue(keyName).ObjectValue;
                if (dataArray.HasValue(key))
                {
                    var value = dataArray.GetValue(key) as ScriptTable;
                    var itor  = data.GetIterator();
                    while (itor.MoveNext())
                    {
                        value.SetValue(itor.Current.Key, itor.Current.Value);
                    }
                }
                else
                {
                    dataArray.SetValue(key, data);
                }
            }
            return(dataArray);
        }
예제 #17
0
 /// <summary>
 /// 스크립트 테이블 추가
 /// </summary>
 /// <param name="scrtbl"></param>
 public void AddScriptTable(ScriptTable scrtbl)
 {
     var id	= scrtbl.Get("id").String;		// NOTE : 반드시 id 필드가 테이블에 존재해야 한다.
     m_tableList[id]	= scrtbl;
 }
예제 #18
0
        private void RebuildTables()
        {
            _lookupTables.Clear();

            // check if this lang has
            GSUB        gsubTable   = _typeface.GSUBTable;
            ScriptTable scriptTable = gsubTable.ScriptList[_language];

            if (scriptTable == null)
            {
                //no script table for request lang-> no lookup process here
                return;
            }

            ScriptTable.LangSysTable selectedLang = null;
            if (scriptTable.langSysTables != null && scriptTable.langSysTables.Length > 0)
            {
                // TODO: review here
                selectedLang = scriptTable.langSysTables[0];
            }
            else
            {
                selectedLang = scriptTable.defaultLang;
            }

            if (selectedLang.HasRequireFeature)
            {
                // TODO: review here
            }

            if (selectedLang.featureIndexList == null)
            {
                return;
            }

            //(one lang may has many features)
            //Enumerate features we want and add the corresponding lookup tables
            foreach (ushort featureIndex in selectedLang.featureIndexList)
            {
                FeatureList.FeatureTable feature = gsubTable.FeatureList.featureTables[featureIndex];
                bool featureIsNeeded             = false;
                switch (feature.TagName)
                {
                case "ccmp":     // glyph composition/decomposition
                    featureIsNeeded = EnableComposition;
                    break;

                case "liga":     // Standard Ligatures --enable by default
                    featureIsNeeded = EnableLigation;
                    break;
                }

                if (featureIsNeeded)
                {
                    foreach (ushort lookupIndex in feature.LookupListIndices)
                    {
                        _lookupTables.Add(gsubTable.LookupList[lookupIndex]);
                    }
                }
            }
        }