Пример #1
0
        static public void StartInitFlow()
        {
            BubConsole.CSay("Looking for Init script!");
            var mainfile = "";

            foreach (string e in SBubble.ResFiles)
            {
                var ce = e.ToUpper();
                if (ce == "INIT.LUA" || qstr.Suffixed(ce, "/INIT.LUA") || ce == "INIT.NIL" || qstr.Suffixed(ce, "/INIT.NIL"))
                {
                    mainfile = e;
                }
            }
            if (mainfile == "")
            {
                Error.GoError("Startup error", "INIT.LUA or INIT.NIL required somewhere in any folder.", "None have been found");
            }
            else
            {
                //mainfile = "Script/Viezelul.lua";
                GoHardFlow(BubConsole.Flow);
                try {
                    BubConsole.WriteLine($"Loading Init Script: {mainfile}");
                    SBubble.NewState("$INIT", mainfile);
                    //SBubble.State("$INIT").state.DoString("local fc = ''\nfor k,v in pairs(_G) do\n fc=fc .. type(v) .. ' ' ..k..'\\n'\n end\n error(fc)"); // debug line
                    SBubble.State("$INIT").state.DoString("assert(type(Bubble_Init)=='function','Function expected for Bubble_Init, got '..type(Bubble_Init))\nBubble_Init()");
                } catch (Exception e) {
                    Error.GoError("Init Error", e.Message, "");
                }
            }
        }
Пример #2
0
        public static void Init(string s)
        {
            var state  = SBubble.State(s).state;
            var script = QuickStream.StringFromEmbed("Bubble_Conf.nil");

            state["Bubble_Conf"] = new Bubble_Conf();
            Debug.WriteLine($"Initiating state: {s}");
            BubConsole.CSay($"State \"{s}\" being prepared for Bubble_Conf");
            SBubble.DoNIL(s, script, "Message box init script");
        }
Пример #3
0
 public void LoadFlow(string flow, string file)
 {
     flow = flow.ToUpper();
     if (!qstr.Prefixed(flow, "FLOW_"))
     {
         flow = $"FLOW_{flow}";
     }
     SBubble.NewState(flow, file);
     BubConsole.WriteLine($"Created new flow: {flow}");
     SBubble.State(flow).state.DoString("if BUB_Load then BUB_Load() end");
 }
Пример #4
0
 static void InitSwap()
 {
     if (SwapMap == null)
     {
         if (SwapFolderSet == "")
         {
             SwapFolderSet = "Swap";
         }
         var ADir = $"{Bubble_Save.SWorkDir}/{SwapFolderSet}";
         BubConsole.WriteLine($"Swap system initialized to folder: {ADir}");
         SwapMap = new Swap(ADir);
     }
 }
Пример #5
0
 public void FreeInstance(string buf)
 {
     try {
         if (!InstanceMap.ContainsKey(buf))
         {
             BubConsole.CSay($"No instance key \"{buf}\" so NOT releasing!"); // debug only!
             return;
         }
         var i = InstanceMap[buf];
         i.Stop(); // I don't want any sound to linger until the C# garbage collector picks this up.
         InstanceMap.Remove(buf);
         InstanceAudioMap.Remove(buf);
         BubConsole.CSay($"Releasing {buf}"); // debug only!
     } catch (Exception Error) {
         SBubble.MyError($"Error on audio instance {buf}", Error.Message, "");
     }
 }
Пример #6
0
        public override void Update(GameTime gameTime)
        {
            //Debug.WriteLine("Hello? Anybody home?");

            /*
             * if (FlowManager.KB.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Escape)) FlowManager.TimeToDie = true;
             * if (FlowManager.KB.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.F1)) BubConsole.GoConsole();
             */
            if (TQMGKey.Hit(Microsoft.Xna.Framework.Input.Keys.Escape))
            {
                FlowManager.TimeToDie = true;
            }
            if (TQMGKey.Hit(Microsoft.Xna.Framework.Input.Keys.F1))
            {
                BubConsole.GoConsole();
            }
        }
Пример #7
0
 public void GoToFlow(string flow)
 {
     flow = flow.ToUpper();
     if (!qstr.Prefixed(flow, "FLOW_"))
     {
         flow = $"FLOW_{flow}";
     }
     if (!SBubble.HaveState(flow))
     {
         SBubble.MyError("Flow Management Error", $"GoToFlow: Flow {flow} doesn't exist!", SBubble.TraceLua(State));
     }
     else
     {
         FlowManager.CurrentFlow = flow;
         BubConsole.WriteLine($"Flow set to: {flow}");
         SBubble.State(flow).DoString("if BUB_Arrive then assert(type(BUB_Arrive)=='function','BUB_Arrive must be a function but it is a '..type(BUB_Arrive)) BUB_Arrive() end");
     }
 }
Пример #8
0
        static public void GoError(string ct, string message, string trace)
        {
            blocked = true;
            BubConsole.WriteLine($"ERROR>{message}", 255, 0, 0);
            Debug.WriteLine($"{ct}: {message}\nTraceback:\n{trace}\n\n");
            if (crashed)
            {
                return;
            }
            crashed = true;
            var s = QuickStream.OpenEmbedded("Death.png");

            if (s == null)
            {
                Debug.WriteLine("ERROR! Trying to read Death resulted into null!");
            }
            s.Position = 0;
            Death      = TQMG.GetImage(s);
            sct        = ct;
            smsg       = message;
            strace     = trace;
            FlowManager.GoHardFlow(new Error(), true);
        }
Пример #9
0
 public void Bye()
 {
     BubConsole.CSay("Bye request initiated!");
     FlowManager.TimeToDie = true;
 }