Example #1
0
        public override void DefineApi(LuaInterpreter script)
        {
            base.DefineApi(script);

            script.AddFunction("btn", (Func <int?, int?, object>)Btn);
            script.AddFunction("btnp", (Func <int?, int?, object>)Btnp);
        }
Example #2
0
        public static LuaValue dofile(LuaValue[] values)
        {
            LuaString file       = values[0] as LuaString;
            LuaTable  enviroment = values[1] as LuaTable;

            return(LuaInterpreter.RunFile(file.Text, enviroment));
        }
Example #3
0
        public override void DefineApi(LuaInterpreter script)
        {
            base.DefineApi(script);

            script.AddFunction("pset", (Action <int, int, byte?>)Pset);
            script.AddFunction("pget", (Func <int, int, byte>)Pget);
            script.AddFunction("flip", (Action)Flip);
            script.AddFunction("cls", (Action <byte?>)Cls);

            script.AddFunction("spr", (Action <int, int?, int?, int?, int?, bool, bool>)Spr);
            script.AddFunction("sspr", (Action <int, int, int, int, int, int, int?, int?, bool, bool>)Sspr);

            script.AddFunction("print", (Action <string, int?, int?, byte?>)Print);
            script.AddFunction("map", (Action <int?, int?, int?, int?, int?, int?, byte?>)Map);
            // Old name of map
            script.AddFunction("mapdraw", (Action <int?, int?, int?, int?, int?, int?, byte?>)Map);

            script.AddFunction("line", (Action <int, int, int?, int?, byte?>)Line);
            script.AddFunction("rect", (Action <int, int, int, int, byte?>)Rect);
            script.AddFunction("rectfill", (Action <int, int, int, int, byte?>)Rectfill);
            script.AddFunction("circ", (Action <int, int, double?, byte?>)Circ);
            script.AddFunction("circfill", (Action <int, int, double?, byte?>)Circfill);

            script.AddFunction("sset", (Action <int, int, byte?>)Sset);
            script.AddFunction("sget", (Func <int, int, byte>)Sget);
        }
Example #4
0
        public static void Main()
        {
            var codeReader = new StringReader(_code);
            var rawTokens  = new LuaRawTokenizer();
            var luaTokens  = new LuaTokenizer();

            rawTokens.Reset(codeReader);
            luaTokens.Reset(rawTokens);

            var parser  = new LuaParser();
            var builder = new SyntaxTreeBuilder();

            builder.Start();
            luaTokens.EnsureMoveNext();
            parser.Reset(luaTokens, builder);
            parser.Parse();

            var ast = builder.Finish();

            var env = new Table();

            env.SetRaw(TypedValue.MakeString("print"), TypedValue.MakeNClosure(Print));

            var codeGen = new CodeGenerator();
            var closure = codeGen.Compile(ast, env);

            var thread = new Thread();
            var stack  = thread.AllocateRootCSharpStack(1);

            var arg = TypedValue.MakeString("C#");

            stack.Write(0, in arg);
            LuaInterpreter.Execute(stack, closure, 0, 1);
            stack.Read(0, out var ret);
        }
        public override void DefineApi(LuaInterpreter script)
        {
            base.DefineApi(script);

            script.AddFunction("music", (Action <int, int?, int?>)Music);
            script.AddFunction("sfx", (Action <int, int?, int?, int?>)Sfx);
        }
Example #6
0
    public void Start()
    {
        lua = Global.Instance().Lua;

        lua.LoadDefines(DefinesPath);

        // immediate functions
        lua.GlobalContext.Globals["addItem"]    = (Action <DynValue>)AddItem;
        lua.GlobalContext.Globals["deductItem"] = (Action <DynValue>)DeductItem;
        lua.GlobalContext.Globals["hasItem"]    = (Func <DynValue, DynValue>)HasItem;
    }
Example #7
0
    IEnumerator ExecuteEvent(string script)
    {
        var interpreter = new LuaInterpreter(script); // スクリプトを渡して初期化

        interpreter.AddHandler("player", player);     // メッセージ制御のハンドラを登録
        interpreter.AddHandler("event", eventData);   // メッセージ制御のハンドラを登録
        while (interpreter.HasNextScript())
        {
            interpreter.Resume();
            yield return(interpreter.WaitCoroutine());
        }
    }
Example #8
0
        public void DefineApi(LuaInterpreter script)
        {
            script.AddFunction("color", (Action <byte?>)Color);
            script.AddFunction("cursor", (Action <int?, int?>)Cursor);
            script.AddFunction("fillp", (Action <double?>)Fillp);
            script.AddFunction("camera", (Action <int?, int?>)Camera);
            script.AddFunction("pal", (Action <int?, int?, int>)Pal);
            script.AddFunction("palt", (Action <int?, bool>)Palt);
            script.AddFunction("clip", (Action <int?, int?, int?, int?>)Clip);

            Palt();
        }
Example #9
0
        public void InitApi(LuaInterpreter script)
        {
            foreach (var unit in units)
            {
                unit.DefineApi(script);
            }

            script.AddFunction("printh", (Action <object>)Printh);
            script.AddFunction("stat", (Func <object>)Stat);
            script.AddFunction("menuitem", (Action <int, string, object>)Menuitem);

            script.RunScript(LuaPatcher.PatchCode(Api.All));
        }
Example #10
0
        /// <summary>
        /// Desktops the load.
        /// </summary>
        /// <returns>The load.</returns>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        private void Desktop_Load(object sender, EventArgs e)
        {
            SaveSystem.IsSandbox = this.IsSandbox;
            SaveSystem.Begin();

            SetupDesktop();

            SaveSystem.GameReady += () =>
            {
                this.Invoke(new Action(() =>
                {
                    LuaInterpreter.RaiseEvent("on_desktop_load", this);
                }));
            };
        }
        public override void DefineApi(LuaInterpreter script)
        {
            base.DefineApi(script);

            script.AddFunction("memset", (Func <int, byte, int, object>)Memset);
            script.AddFunction("memcpy", (Func <int, int, int, object>)Memcpy);
            script.AddFunction("peek", (Func <int, byte>)Peek);
            script.AddFunction("poke", (Func <int, byte, object>)Poke);

            script.AddFunction("fget", (Func <int, byte?, object>)Fget);
            script.AddFunction("fset", (Action <int, byte?, bool?>)Fset);
            script.AddFunction("mget", (Func <int, int, byte>)Mget);
            script.AddFunction("mset", (Action <int, int, byte>)Mset);

            drawState.DefineApi(script);
        }
Example #12
0
        public static LuaValue loadstring(LuaValue[] values)
        {
            LuaString code       = values[0] as LuaString;
            LuaTable  enviroment = values[1] as LuaTable;
            Chunk     chunk      = LuaInterpreter.Parse(code.Text);

            LuaFunction func = new LuaFunction(
                (LuaValue[] args) =>
            {
                chunk.Enviroment = enviroment;
                return(chunk.Execute());
            }
                );

            return(func);
        }
        public override void DefineApi(LuaInterpreter script)
        {
            base.DefineApi(script);

            script.AddFunction("reload", (Action <int, int, int, string>)Reload);
            script.AddFunction("cstore", (Action <int, int, int, string>)Cstore);
            script.AddFunction("cartdata", (Action <string>)Cartdata);
            script.AddFunction("dget", (Func <int, object>)Dget);
            script.AddFunction("dset", (Action <int, double>)Dset);
            script.AddFunction("import", (Action <string, bool>)Import);
            script.AddFunction("export", (Action <string>)Export);
            script.AddFunction("run", (Action)Run);

            script.AddFunction("time", (Func <double>)Time);
            script.AddFunction("t", (Func <double>)Time);
        }
Example #14
0
        public void SetupAdvancedCategory(string cat)
        {
            flapps.Controls.Clear();

            foreach (var app in LauncherItemList[cat])
            {
                var catbtn = new Button();
                catbtn.Font      = LoadedSkin.AdvALItemFont;
                catbtn.FlatStyle = FlatStyle.Flat;
                catbtn.FlatAppearance.BorderSize         = 0;
                catbtn.FlatAppearance.MouseOverBackColor = LoadedSkin.Menu_MenuItemSelected;
                catbtn.FlatAppearance.MouseDownBackColor = LoadedSkin.Menu_MenuItemPressedGradientBegin;
                catbtn.BackColor   = LoadedSkin.Menu_ToolStripDropDownBackground;
                catbtn.ForeColor   = LoadedSkin.Menu_TextColor;
                catbtn.MouseEnter += (o, a) =>
                {
                    catbtn.ForeColor = LoadedSkin.Menu_SelectedTextColor;
                };
                catbtn.MouseLeave += (o, a) =>
                {
                    catbtn.ForeColor = LoadedSkin.Menu_TextColor;
                };
                catbtn.TextAlign  = ContentAlignment.MiddleLeft;
                catbtn.Text       = (app is LuaLauncherItem) ? app.DisplayData.Name : NameChangerBackend.GetNameRaw(app.LaunchType);
                catbtn.Width      = flapps.Width;
                catbtn.ImageAlign = ContentAlignment.MiddleRight;
                catbtn.Height     = 24;
                catbtn.Image      = (app.LaunchType == null) ? null : SkinEngine.GetIcon(app.LaunchType.Name);

                flapps.Controls.Add(catbtn);
                catbtn.Show();
                catbtn.Click += (o, a) =>
                {
                    pnladvancedal.Hide();
                    if (app is LuaLauncherItem)
                    {
                        var interp = new LuaInterpreter();
                        interp.ExecuteFile((app as LuaLauncherItem).LaunchPath);
                    }
                    else
                    {
                        IShiftOSWindow win = Activator.CreateInstance(app.LaunchType) as IShiftOSWindow;
                        AppearanceManager.SetupWindow(win);
                    }
                };
            }
        }
    IEnumerator ExecuteEvent(string script)
    {
        var interpreter = new LuaInterpreter(script); // スクリプトを渡して初期化

        interpreter.AddHandler("player", player);
        interpreter.AddHandler("npcGirl", npcGirl);
        interpreter.AddHandler("npcBoy", npcBoy);
        interpreter.AddHandler("message", messagePanel);
        interpreter.AddHandler("camera", camera);
        interpreter.AddHandler("fadePanel", fadePanel);
        interpreter.AddHandler("oldPlayer", oldPlayer);
        interpreter.AddHandler("sound", sound);
        interpreter.AddHandler("chocolate", chocolate);
        interpreter.AddHandler("select", select);
        interpreter.AddHandler("flag", flag);
        interpreter.AddHandler("sceneLoader", SceneLoader.instance);
        yield return(new WaitForSeconds(2));

        int?result = null;

        while (interpreter.HasNextScript())
        {
            if (SceneLoader.instance.currentScene != "MainStory")
            {
                yield return(null);
            }
            interpreter.Resume(result);
            yield return(interpreter.WaitCoroutine());

            if (interpreter.resultValue != null)
            {
                result = interpreter.resultValue.Value;
            }
            else
            {
                result = null;
            }
        }
        yield return(null);

        yield return(new WaitUntil(() => Input.GetKeyDown(KeyCode.Space)));

        PlayerPrefs.SetInt("CLEAR", 1);
        UnityEngine.SceneManagement.SceneManager.LoadScene("MainStory");
    }
    IEnumerator ExecuteEvent(string script)
    {
        var interpreter = new LuaInterpreter(script); // スクリプトを渡して初期化

        interpreter.AddHandler("player", player);
        interpreter.AddHandler("npcGirl", npcGirl);
        interpreter.AddHandler("npcBoy", npcBoy);
        interpreter.AddHandler("message", messagePanel);
        interpreter.AddHandler("camera", camera);
        interpreter.AddHandler("fadePanel", fadePanel);
        interpreter.AddHandler("oldPlayer", oldPlayer);
        interpreter.AddHandler("sound", sound);
        interpreter.AddHandler("chocolate", chocolate);
        yield return(new WaitForSeconds(2));

        while (interpreter.HasNextScript())
        {
            interpreter.Resume();
            yield return(interpreter.WaitCoroutine());
        }
    }
Example #17
0
        public static void DoString(string str, Table env, Span <TypedValue> args, Span <TypedValue> results)
        {
            var closure = Compile(str, env);

            var thread    = new Thread();
            var stackSize = Math.Max(args.Length, results.Length);
            var stack     = thread.AllocateRootCSharpStack(stackSize);

            if (args.Length > 0)
            {
                throw new NotImplementedException();
            }
            stack.Write(0, args);

            var retCount = LuaInterpreter.Execute(thread, closure, stack, 0, 0);

            stack.Read(0, results);
            for (int i = retCount; i < results.Length; ++i)
            {
                results[i] = TypedValue.Nil;
            }
        }
Example #18
0
        public void TestAdd()
        {
            var closure = TestHelper.Compile("return function(a, b) return a + b end", null);

            var thread = new Thread();
            var stack  = thread.AllocateRootCSharpStack(3);

            var retCount = LuaInterpreter.Execute(stack, closure, 0, 0);

            Assert.AreEqual(1, retCount);
            stack.Read(0, out var retVal);

            Assert.AreEqual(LuaValueType.LClosure, retVal.ValueType);
            var retClosure = retVal.LClosureVal;

            //First call at offset 1: add(1, 2).

            stack.Write(1, TypedValue.MakeDouble(1));
            stack.Write(2, TypedValue.MakeDouble(2));
            retCount = LuaInterpreter.Execute(stack, retClosure, 1, 2);
            Assert.AreEqual(1, retCount);
            stack.Read(1, out retVal);

            Assert.AreEqual(LuaValueType.Number, retVal.ValueType);
            Assert.AreEqual(3, retVal.NumberVal);

            //Second call at offset 0: add(3, ret).

            stack.Write(0, TypedValue.MakeDouble(3));
            retCount = LuaInterpreter.Execute(stack, retClosure, 0, 2);
            Assert.AreEqual(1, retCount);
            stack.Read(0, out retVal);

            Assert.AreEqual(LuaValueType.Number, retVal.ValueType);
            Assert.AreEqual(6, retVal.NumberVal);
        }
        public override void DefineApi(LuaInterpreter script)
        {
            script.AddFunction("rnd", (Func <double?, double>)Rnd);
            script.AddFunction("srand", (Action <int>)Srand);

            script.AddFunction("flr", (Func <double, double>)Flr);
            script.AddFunction("sgn", (Func <double, double>)Sgn);
            script.AddFunction("max", (Func <double, double, double>)Max);
            script.AddFunction("min", (Func <double, double, double>)Min);
            script.AddFunction("mid", (Func <double, double, double, double>)Mid);
            script.AddFunction("abs", (Func <double, double>)Abs);
            script.AddFunction("sqrt", (Func <double, double>)Sqrt);

            script.AddFunction("cos", (Func <double, double>)Cos);
            script.AddFunction("sin", (Func <double, double>)Sin);
            script.AddFunction("atan2", (Func <double, double, double>)Atan2);

            script.AddFunction("band", (Func <float, float, double>)Band);
            script.AddFunction("bor", (Func <float, float, double>)Bor);
            script.AddFunction("bxor", (Func <float, float, double>)Bxor);
            script.AddFunction("bnot", (Func <float, double>)Bnot);
            script.AddFunction("shl", (Func <float, int, double>)Shl);
            script.AddFunction("shr", (Func <float, int, double>)Shr);
        }
Example #20
0
        /// <summary>
        /// Populates the panel buttons.
        /// </summary>
        /// <returns>The panel buttons.</returns>
        public void PopulatePanelButtons()
        {
            if (DesktopFunctions.ShowDefaultElements == true)
            {
                panelbuttonholder.Controls.Clear();
                if (Shiftorium.IsInitiated == true)
                {
                    if (Shiftorium.UpgradeInstalled("wm_panel_buttons"))
                    {
                        foreach (WindowBorder form in Engine.AppearanceManager.OpenForms)
                        {
                            if (form != null)
                            {
                                if (form.Visible == true)
                                {
                                    EventHandler onClick = (o, a) =>
                                    {
                                        if (form == focused)
                                        {
                                            if (form.IsMinimized)
                                            {
                                                RestoreWindow(form);
                                            }
                                            else
                                            {
                                                MinimizeWindow(form);
                                            }
                                        }
                                        else
                                        {
                                            form.BringToFront();
                                            focused = form;
                                        }
                                        HideAppLauncher();
                                    };

                                    var pnlbtn = new Panel();
                                    pnlbtn.Margin                = new Padding(2, LoadedSkin.PanelButtonFromTop, 0, 0);
                                    pnlbtn.BackColor             = LoadedSkin.PanelButtonColor;
                                    pnlbtn.BackgroundImage       = GetImage("panelbutton");
                                    pnlbtn.BackgroundImageLayout = GetImageLayout("panelbutton");

                                    var pnlbtntext = new Label();
                                    pnlbtntext.Text      = NameChangerBackend.GetName(form.ParentWindow);
                                    pnlbtntext.AutoSize  = true;
                                    pnlbtntext.Location  = LoadedSkin.PanelButtonFromLeft;
                                    pnlbtntext.ForeColor = LoadedSkin.PanelButtonTextColor;
                                    pnlbtntext.BackColor = Color.Transparent;

                                    pnlbtn.BackColor = LoadedSkin.PanelButtonColor;
                                    if (pnlbtn.BackgroundImage != null)
                                    {
                                        pnlbtntext.BackColor = Color.Transparent;
                                    }
                                    pnlbtn.Size    = LoadedSkin.PanelButtonSize;
                                    pnlbtn.Tag     = "keepbg";
                                    pnlbtntext.Tag = "keepbg";
                                    pnlbtn.Controls.Add(pnlbtntext);
                                    this.panelbuttonholder.Controls.Add(pnlbtn);
                                    pnlbtn.Show();
                                    pnlbtntext.Show();

                                    if (Shiftorium.UpgradeInstalled("useful_panel_buttons"))
                                    {
                                        pnlbtn.Click     += onClick;
                                        pnlbtntext.Click += onClick;
                                    }
                                    pnlbtntext.Font = LoadedSkin.PanelButtonFont;
                                }
                            }
                        }
                    }
                }
            }

            LuaInterpreter.RaiseEvent("on_panelbutton_populate", this);
        }
Example #21
0
 public bool OnUnload()
 {
     LuaInterpreter.RaiseEvent("on_window_unload", this);
     return(true);
 }
Example #22
0
        /// <summary>
        /// Setups the desktop.
        /// </summary>
        /// <returns>The desktop.</returns>
        public void SetupDesktop()
        {
            if (DesktopFunctions.ShowDefaultElements == true)
            {
                ToolStripManager.Renderer = new ShiftOSMenuRenderer();

                this.DoubleBuffered    = true;
                this.FormBorderStyle   = FormBorderStyle.None;
                this.WindowState       = FormWindowState.Maximized;
                desktoppanel.BackColor = Color.Green;

                //upgrades

                if (Shiftorium.IsInitiated == true)
                {
                    desktoppanel.Visible = Shiftorium.UpgradeInstalled("desktop");
                    lbtime.Visible       = Shiftorium.UpgradeInstalled("desktop_clock_widget");

                    ControlManager.SetupControls(pnlnotificationbox);

                    //skinning
                    lbtime.BackColor = Color.Transparent;
                    pnlnotifications.BackgroundImage       = GetImage("panelclockbg");
                    pnlnotifications.BackgroundImageLayout = GetImageLayout("panelclockbg");
                    pnlnotifications.BackColor             = LoadedSkin.DesktopPanelClockBackgroundColor;

                    panelbuttonholder.Top       = 0;
                    panelbuttonholder.Left      = LoadedSkin.PanelButtonHolderFromLeft;
                    panelbuttonholder.Height    = desktoppanel.Height;
                    panelbuttonholder.BackColor = Color.Transparent;
                    panelbuttonholder.Margin    = new Padding(0, 0, 0, 0);

                    sysmenuholder.Visible = Shiftorium.UpgradeInstalled("app_launcher");

                    //The Color Picker can give us transparent colors - which Windows Forms f*****g despises when dealing with form backgrounds.
                    //To compensate, we must recreate the desktop color and make the alpha channel '255'.
                    this.BackColor = Color.FromArgb(LoadedSkin.DesktopColor.R, LoadedSkin.DesktopColor.G, LoadedSkin.DesktopColor.B);
                    //Not doing this will cause an ArgumentException.

                    this.BackgroundImage       = SkinEngine.GetImage("desktopbackground");
                    this.BackgroundImageLayout = GetImageLayout("desktopbackground");
                    desktoppanel.BackColor     = LoadedSkin.DesktopPanelColor;

                    var pnlimg = GetImage("desktoppanel");
                    if (pnlimg != null)
                    {
                        var bmp = new Bitmap(pnlimg);
                        bmp.MakeTransparent(Color.FromArgb(1, 0, 1));
                        pnlimg = bmp;
                    }

                    desktoppanel.BackgroundImage = pnlimg;
                    if (desktoppanel.BackgroundImage != null)
                    {
                        desktoppanel.BackColor = Color.Transparent;
                    }
                    var appimg = GetImage("applauncher");
                    if (appimg != null)
                    {
                        var bmp = new Bitmap(appimg);
                        bmp.MakeTransparent(Color.FromArgb(1, 0, 1));
                        appimg = bmp;
                    }
                    menuStrip1.BackgroundImage = appimg;
                    lbtime.ForeColor           = LoadedSkin.DesktopPanelClockColor;
                    lbtime.Font = LoadedSkin.DesktopPanelClockFont;
                    if (desktoppanel.BackgroundImage == null)
                    {
                        lbtime.BackColor = LoadedSkin.DesktopPanelClockBackgroundColor;
                    }
                    else
                    {
                        lbtime.BackColor = Color.Transparent;
                    }
                    apps.Text = LoadedSkin.AppLauncherText;
                    sysmenuholder.Location = LoadedSkin.AppLauncherFromLeft;
                    sysmenuholder.Size     = LoadedSkin.AppLauncherHolderSize;
                    apps.Size           = sysmenuholder.Size;
                    menuStrip1.Renderer = new ShiftOSMenuRenderer(new AppLauncherColorTable());
                    desktoppanel.BackgroundImageLayout = GetImageLayout("desktoppanel");
                    desktoppanel.Height = LoadedSkin.DesktopPanelHeight;
                    if (LoadedSkin.DesktopPanelPosition == 1)
                    {
                        desktoppanel.Dock = DockStyle.Bottom;
                    }
                    else
                    {
                        desktoppanel.Dock = DockStyle.Top;
                    }
                }

                pnlwidgetlayer.Show();
                pnlwidgetlayer.BringToFront();

                if (Shiftorium.UpgradeInstalled("desktop_widgets"))
                {
                    Widgets.Clear();
                    pnlwidgetlayer.Controls.Clear();
                    foreach (var widget in WidgetManager.GetAllWidgetTypes())
                    {
                        UserControl w = (UserControl)Activator.CreateInstance(widget.Value, null);

                        w.Location = WidgetManager.LoadDetails(w.GetType()).Location;
                        pnlwidgetlayer.Controls.Add(w);
                        MakeWidgetMovable(w);
                        Widgets.Add(w as IDesktopWidget);
                    }
                }

                int lastHeight = 5;
                foreach (var widget in Widgets)
                {
                    if (WidgetManager.LoadDetails(widget.GetType()).IsVisible&& Shiftorium.UpgradeInstalled("desktop_widgets"))
                    {
                        widget.OnSkinLoad();

                        widget.OnUpgrade();
                        widget.Setup();
                        widget.Show();
                        if (widget.Location.X == -1 && widget.Location.Y == -1)
                        {
                            widget.Location = new Point(5, lastHeight);
                            lastHeight     += widget.Size.Height + 5;
                        }
                    }
                    else
                    {
                        widget.Hide();
                    }
                }
                pnlwidgetlayer.Show();
                pnlwidgetlayer.BringToFront();
            }
            else
            {
                desktoppanel.Hide();
            }

            LuaInterpreter.RaiseEvent("on_desktop_skin", this);

            PopulatePanelButtons();
        }
Example #23
0
 public void OnUpgrade()
 {
     LuaInterpreter.RaiseEvent("on_window_upgrade", this);
 }
Example #24
0
 public static void Dispose()
 {
     mGenerator     = null;
     mInterpreter   = null;
     mVariableNames = null;
 }
Example #25
0
    public static void Test()
    {
        LuaInterpreter interpreter = new LuaInterpreter();

        interpreter.Run();
    }
Example #26
0
 public void OnSkinLoad()
 {
     LuaInterpreter.RaiseEvent("on_window_skin_load", this);
 }
Example #27
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            _spriteBatch = new MySpriteBatch(GraphicsDevice);

            Utils.FontManager.Instance.LoadFonts(this);

            EmptyKeys.UserInterface.FontManager.DefaultFont = Engine.Instance.Renderer.CreateFont(Utils.FontManager.Instance.GetFont(FontEnum.ARIAL_16));
            Viewport viewport = GraphicsDevice.Viewport;

            _basicUI             = new EmptyKeys.UserInterface.Generated.BasicUI();
            _viewModel           = new BasicUIViewModel();
            _basicUI.DataContext = _viewModel;

            EmptyKeys.UserInterface.FontManager.Instance.LoadFonts(Content, "Fonts/");
            ImageManager.Instance.LoadImages(Content);
            SoundManager.Instance.LoadSounds(Content);

            var spriteSheet = Content.Load <Texture2D>("Textures/spritesheet");

            TextureManager = new TextureManager(spriteSheet, 32, 32);

            Lua = new LuaInterpreter();

            _threadLua = new Thread(
                new ThreadStart(ConsoleThread));
            _threadLua.Start();

            World = new World();

            var drawSystem = new DrawEntitySystem(
                1,
                new List <Type>()
            {
                typeof(SpriteComponent), typeof(TransformComponent)
            },
                World
                );

            var random = new Random();

            var player = World.CreateGameObject();

            FactoryEntity.CreatePlayer(World, player);

            var bomb = World.CreateGameObject();

            FactoryEntity.CreateBomb(World, bomb, 6, 1);

            var map = new int[MapWidth * MapHeight]
            {
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
                0, 1, 2, 0, 2, 0, 2, 0, 1, 0,
                0, 1, 2, 0, 2, 0, 2, 0, 1, 0,
                0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
                0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
                0, 1, 0, 0, 0, 0, 0, 0, 1, 0,
                0, 1, 0, 0, 0, 0, 0, 0, 1, 0,
                0, 1, 1, 1, 1, 1, 1, 1, 1, 0,
                0, 0, 0, 0, 0, 0, 0, 0, 0, 0
            };

            for (var i = 0; i < map.Length; i++)
            {
                var e = World.CreateGameObject();

                var value = map[i];
                switch (value)
                {
                case 0:
                    FactoryEntity.CreateHardWall(World, e, i % MapWidth, i / MapHeight);
                    break;

                case 2:
                    FactoryEntity.CreateSoftWall(World, e, i % MapWidth, i / MapHeight);
                    break;
                }
            }

            World.SystemManager.AddSystem(new UpdateSpriteSystem(0,
                                                                 new List <Type>()
            {
                typeof(SpriteComponent), typeof(SpriteAnimationComponent)
            },
                                                                 World));
            World.SystemManager.AddSystem(new UpdateInputSystem(0,
                                                                new List <Type>()
            {
                typeof(TypeEntityComponent), typeof(TransformComponent), typeof(InputComponent)
            },
                                                                World));

            World.SystemManager.AddSystem(new DrawFloorSystem(0, null, World));
            World.SystemManager.AddSystem(drawSystem);

            _stopwatch = new Stopwatch();
            _stopwatch.Start();
        }
Example #28
0
        /// <summary>
        /// Populates the app launcher.
        /// </summary>
        /// <returns>The app launcher.</returns>
        /// <param name="items">Items.</param>
        public void PopulateAppLauncher(LauncherItem[] items)
        {
            if (Shiftorium.UpgradeInstalled("advanced_app_launcher"))
            {
                pnladvancedal.Visible        = false;
                flapps.BackColor             = LoadedSkin.Menu_ToolStripDropDownBackground;
                flcategories.BackColor       = LoadedSkin.Menu_ToolStripDropDownBackground;
                pnlalsystemactions.BackColor = LoadedSkin.SystemPanelBackground;
                lbalstatus.BackColor         = LoadedSkin.ALStatusPanelBackColor;
                //Fonts
                lbalstatus.Font      = LoadedSkin.ALStatusPanelFont;
                lbalstatus.ForeColor = LoadedSkin.ALStatusPanelTextColor;
                btnshutdown.Font     = LoadedSkin.ShutdownFont;

                //Upgrades
                btnshutdown.Visible = Shiftorium.UpgradeInstalled("al_shutdown");

                //Alignments and positions.
                lbalstatus.TextAlign = LoadedSkin.ALStatusPanelAlignment;
                if (LoadedSkin.ShutdownButtonStyle == 2)
                {
                    btnshutdown.Hide();
                }
                else if (LoadedSkin.ShutdownButtonStyle == 1)
                {
                    btnshutdown.Parent = pnlstatus;
                    btnshutdown.BringToFront();
                }
                else
                {
                    btnshutdown.Parent = pnlalsystemactions;
                }
                if (LoadedSkin.ShutdownOnLeft)
                {
                    btnshutdown.Location = LoadedSkin.ShutdownButtonFromSide;
                }
                else
                {
                    btnshutdown.Left = (btnshutdown.Parent.Width - btnshutdown.Width) - LoadedSkin.ShutdownButtonFromSide.X;
                    btnshutdown.Top  = LoadedSkin.ShutdownButtonFromSide.Y;
                }

                //Images
                lbalstatus.BackgroundImage       = GetImage("al_bg_status");
                lbalstatus.BackgroundImageLayout = GetImageLayout("al_bg_status");

                pnlalsystemactions.BackgroundImage       = GetImage("al_bg_system");
                pnlalsystemactions.BackgroundImageLayout = GetImageLayout("al_bg_system");
                if (pnlalsystemactions.BackgroundImage != null)
                {
                    btnshutdown.BackColor = Color.Transparent;
                }

                btnshutdown.Font      = LoadedSkin.ShutdownFont;
                btnshutdown.ForeColor = LoadedSkin.ShutdownForeColor;

                pnladvancedal.Size = LoadedSkin.AALSize;

                pnlalsystemactions.Height = LoadedSkin.ALSystemActionHeight;
                pnlstatus.Height          = LoadedSkin.ALSystemStatusHeight;

                flcategories.Width = LoadedSkin.AALCategoryViewWidth;
                this.flapps.Width  = LoadedSkin.AALItemViewWidth;
            }


            if (DesktopFunctions.ShowDefaultElements == true)
            {
                apps.DropDownItems.Clear();

                Dictionary <string, List <ToolStripMenuItem> > sortedItems = new Dictionary <string, List <ToolStripMenuItem> >();

                flcategories.Controls.Clear();

                LauncherItemList.Clear();


                foreach (var kv in items)
                {
                    var item = new ToolStripMenuItem();
                    item.Text   = (kv.LaunchType == null) ? kv.DisplayData.Name : Applications.NameChangerBackend.GetNameRaw(kv.LaunchType);
                    item.Image  = (kv.LaunchType == null) ? null : SkinEngine.GetIcon(kv.LaunchType.Name);
                    item.Click += (o, a) =>
                    {
                        if (kv is LuaLauncherItem)
                        {
                            var interpreter = new Engine.Scripting.LuaInterpreter();
                            interpreter.ExecuteFile((kv as LuaLauncherItem).LaunchPath);
                        }
                        else
                        {
                            Engine.AppearanceManager.SetupWindow(Activator.CreateInstance(kv.LaunchType) as IShiftOSWindow);
                        }
                    };
                    if (sortedItems.ContainsKey(kv.DisplayData.Category))
                    {
                        sortedItems[kv.DisplayData.Category].Add(item);
                        LauncherItemList[kv.DisplayData.Category].Add(kv);
                    }
                    else
                    {
                        sortedItems.Add(kv.DisplayData.Category, new List <ToolStripMenuItem>());
                        sortedItems[kv.DisplayData.Category].Add(item);
                        LauncherItemList.Add(kv.DisplayData.Category, new List <LauncherItem> {
                            kv
                        });
                    }
                }

                foreach (var kv in sortedItems)
                {
                    if (Shiftorium.IsInitiated == true)
                    {
                        if (Shiftorium.UpgradeInstalled("app_launcher_categories"))
                        {
                            var cat = GetALCategoryWithName(kv.Key);
                            foreach (var subItem in kv.Value)
                            {
                                cat.DropDownItems.Add(subItem);
                            }
                            if (Shiftorium.UpgradeInstalled("advanced_app_launcher"))
                            {
                                var catbtn = new Button();
                                catbtn.Font      = LoadedSkin.AdvALItemFont;
                                catbtn.FlatStyle = FlatStyle.Flat;
                                catbtn.FlatAppearance.BorderSize         = 0;
                                catbtn.FlatAppearance.MouseOverBackColor = LoadedSkin.Menu_MenuItemSelected;
                                catbtn.FlatAppearance.MouseDownBackColor = LoadedSkin.Menu_MenuItemPressedGradientBegin;
                                catbtn.BackColor   = LoadedSkin.Menu_ToolStripDropDownBackground;
                                catbtn.TextAlign   = ContentAlignment.MiddleLeft;
                                catbtn.ForeColor   = LoadedSkin.Menu_TextColor;
                                catbtn.MouseEnter += (o, a) =>
                                {
                                    catbtn.ForeColor = LoadedSkin.Menu_SelectedTextColor;
                                };
                                catbtn.MouseLeave += (o, a) =>
                                {
                                    catbtn.ForeColor = LoadedSkin.Menu_TextColor;
                                };
                                catbtn.Text   = kv.Key;
                                catbtn.Width  = flcategories.Width;
                                catbtn.Height = 24;
                                flcategories.Controls.Add(catbtn);
                                catbtn.Show();
                                catbtn.Click += (o, a) => SetupAdvancedCategory(catbtn.Text);
                            }
                        }

                        else
                        {
                            foreach (var subItem in kv.Value)
                            {
                                apps.DropDownItems.Add(subItem);
                            }
                        }
                    }
                }

                if (Shiftorium.IsInitiated == true)
                {
                    if (Shiftorium.UpgradeInstalled("al_shutdown"))
                    {
                        apps.DropDownItems.Add(new ToolStripSeparator());
                        var item = new ToolStripMenuItem();
                        item.Text   = Localization.Parse("{SHUTDOWN}");
                        item.Click += (o, a) =>
                        {
                            TerminalBackend.InvokeCommand("shutdown");
                        };
                        apps.DropDownItems.Add(item);
                        if (Shiftorium.UpgradeInstalled("advanced_app_launcher"))
                        {
                            if (LoadedSkin.ShutdownButtonStyle == 2)
                            {
                                var catbtn = new Button();
                                catbtn.Font      = LoadedSkin.AdvALItemFont;
                                catbtn.FlatStyle = FlatStyle.Flat;
                                catbtn.FlatAppearance.BorderSize         = 0;
                                catbtn.FlatAppearance.MouseOverBackColor = LoadedSkin.Menu_MenuItemSelected;
                                catbtn.FlatAppearance.MouseDownBackColor = LoadedSkin.Menu_MenuItemPressedGradientBegin;
                                catbtn.BackColor   = LoadedSkin.Menu_ToolStripDropDownBackground;
                                catbtn.ForeColor   = LoadedSkin.Menu_TextColor;
                                catbtn.MouseEnter += (o, a) =>
                                {
                                    catbtn.ForeColor = LoadedSkin.Menu_SelectedTextColor;
                                };
                                catbtn.MouseLeave += (o, a) =>
                                {
                                    catbtn.ForeColor = LoadedSkin.Menu_TextColor;
                                };

                                catbtn.TextAlign = ContentAlignment.MiddleLeft;
                                catbtn.Text      = "Shutdown";
                                catbtn.Width     = flcategories.Width;
                                catbtn.Height    = 24;
                                flcategories.Controls.Add(catbtn);
                                catbtn.Show();
                                catbtn.Click += (o, a) => TerminalBackend.InvokeCommand("shutdown");
                            }
                        }
                    }
                }
            }
            LuaInterpreter.RaiseEvent("on_al_populate", items);
        }
Example #29
0
 public virtual void DefineApi(LuaInterpreter script)
 {
 }