public string Load(string file, string assign = "") { try { var tag = assign; var at = 0; if (tag == "") { do { at++; tag = $"IMAGE:{at}"; } while (Images.ContainsKey(tag)); } if (qstr.Suffixed(file.ToLower(), ".jpbf")) { Images[tag] = TQMG.GetBundle(file); } else { Images[tag] = TQMG.GetImage(file); } if (Images[tag] == null) { throw new Exception($"Filed loading {file} at {tag}\n{UseJCR6.JCR6.JERROR}"); } return(tag); } catch (Exception Catastrophe) { #if DEBUG SBubble.MyError($"Bubble.Graphics.Images.Load(\"{file}\",\"{assign}\")", Catastrophe.Message, $"{SBubble.TraceLua(vm)}\n\n.NET Traceback:\n{Catastrophe.StackTrace}"); #else SBubble.MyError($"Bubble.Graphics.Images.Load(\"{file}\",\"{assign}\")", Catastrophe.Message, $"{SBubble.TraceLua(vm)}"); #endif return("Il ya une catastrophe"); } }
void VisByLabel(int ID, string label, bool value) { try { var L = KMaps[ID].Layers[Layers[ID]]; if (!L.LabelMap.ContainsKey(label)) { Console.Beep(); BubConsole.CSay($"WARNING! Label '{label}' not found!"); foreach (string k in L.LabelMap.Keys) { BubConsole.CSay("= Has label: '{label}'"); } } foreach (KthuraObject O in L.LabelMap[label]) { O.Visible = value; } } catch (Exception Poepzooitje) { #if DEBUG SBubble.MyError($"Kthura.VisByLabel({ID},\"{label}\",{value}):", Poepzooitje.Message, $"{LuaTrace}\n\nC# Trace{Poepzooitje.StackTrace}"); #else SBubble.MyError($"Kthura.VisByLabel({ID},\"{label}\",{value}):", Poepzooitje.Message, LuaTrace); #endif } }
public static bool SwapLoad(UseJCR6.TJCRDIR j, string dir) { try { //if (SwapMap == null) SwapMap = new Swap("Swap"); InitSwap(); SwapMap.Clear(); foreach (string k in j.Entries.Keys) { if (qstr.ExtractDir(k) == $"XTRA/{dir.ToUpper()}") { var key = qstr.StripDir(k); SwapMap[key] = j.LoadString(k); } } return(true); } catch (Exception EpicFail) { SBubble.MyError("Error while extracting swap data", EpicFail.Message, #if DEBUG EpicFail.StackTrace); #else ""); #endif return(false); } }
public string IPlay(string buf, bool loop) { var tag = ""; try { if (!AudioMap.ContainsKey(buf)) { throw new Exception($"No audio buffer tagged {buf} available"); } var i = AudioMap[buf].CreateInstance(); var c = 0; do { c++; tag = $"INSTANCE{c.ToString("X10")}"; } while (InstanceMap.ContainsKey(tag)); InstanceAudioMap[tag] = buf; InstanceMap[tag] = i; i.IsLooped = loop; i.Play(); } catch (Exception huh) { SBubble.MyError("Odd things happen here!", huh.Message, huh.StackTrace); } return(tag); }
public void VisibleOnlyByZone(int id, string tag, bool inzone) { try { var lname = Layers[id]; var m = KMaps[id]; var l = m.Layers[lname]; if (!l.HasTag(tag)) { throw new Exception("I cannot hide or show by a non-existent zone"); } var zone = l.FromTag(tag); if (zone.kind != "TiledArea" && zone.kind != "Zone") { throw new Exception($"Object '{tag}' is a {zone.kind} which is not valid for a visible by zone change!"); } foreach (KthuraObject o in l.Objects) { if (o != zone) { if (inzone) { o.Visible = o.x >= zone.x && o.y >= zone.y && o.x <= zone.x + zone.w && o.y <= zone.y + zone.h; } else { o.Visible = !(o.x >= zone.x && o.y >= zone.y && o.x <= zone.x + zone.w && o.y <= zone.y + zone.h); } } } } catch (Exception EpicFail) { SBubble.MyError($"Kthura.VisilityOnlyByZone[{id},\"{tag}\"]={inzone}:", EpicFail.Message, LuaTrace); } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { try { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); #region Tricky's Quick Monogame Graphics if (SBubble.JCR == null) { System.Diagnostics.Debug.WriteLine("EEP! JCR resource is null! But how?"); } TQMG.Init(graphics, GraphicsDevice, spriteBatch, SBubble.JCR); #endregion BubbleInit.LetsGo(); TrickyGameJolt.GJAPI.ERRORFUNCTION = delegate(string msg) { #if FATAL_GAMEJOLT SBubble.MyError("Game Jolt API Error", msg, ""); #else BubConsole.WriteLine("GAME JOLT ERROR", 255, 0, 0); System.Console.Beep(); BubConsole.WriteLine(msg); #endif }; } catch (System.Exception Allemaal_naar_de_klote) { #if DEBUG Confirm.Annoy($"ERROR!\n{Allemaal_naar_de_klote.Message}\n\n{Allemaal_naar_de_klote.StackTrace}\n", "NALA Init error (LC)", System.Windows.Forms.MessageBoxIcon.Error); #else Confirm.Annoy($"ERROR!\n{Allemaal_naar_de_klote.Message}\n\nDid you install everything propely, or is the engine broken?\n", "NALA Init error (LC)", System.Windows.Forms.MessageBoxIcon.Error); #endif System.Environment.Exit(10); } }
public void SetObjBool(int id, string Lay, string Tag, string stat, bool value) { try { var M = KMaps[id]; var L = M.Layers[Lay]; var T = L.FromTag(Tag); switch (stat.ToUpper()) { case "VISIBLE": T.Visible = value; break; case "IMPASSIBLE": T.Impassible = value; break; case "FORCEPASSIBLE": T.ForcePassible = value; break; default: throw new Exception($"There is no object integer field named: {stat}!"); } } catch (Exception shit) { SBubble.MyError($"Kthura.ObjInt({id},\"{Lay}\",\"{Tag}\",\"{stat}\"):", shit.Message, LuaTrace); return; } }
public bool ObjBool(int id, string Lay, string Tag, string stat) { try { var M = KMaps[id]; var L = M.Layers[Lay]; var T = L.FromTag(Tag); switch (stat.ToUpper()) { case "VISIBLE": return(T.Visible); case "IMPASSIBLE": return(T.Impassible); case "FORCEPASSIBLE": return(T.ForcePassible); default: throw new Exception($"There is no boolean field named: {stat}"); } } catch (Exception shit) { SBubble.MyError($"Kthura.ObjBool({id},\"{Lay}\",\"{Tag}\",\"{stat}\"):", shit.Message, LuaTrace); return(false); } }
public string GrabScreen(string assign = "") { try { var tag = assign; var at = 0; if (tag == "") { do { at++; tag = $"IMAGE:{at}"; } while (Images.ContainsKey(tag)); } Images[tag] = TQMG.GrabImage(); if (Images[tag] == null) { throw new Exception("Grabbed image == null!"); } return(tag); } catch (Exception Catastrophe) { #if DEBUG SBubble.MyError($"Bubble.Graphics.Images.Grab(\"{assign}\")", Catastrophe.Message, $"{SBubble.TraceLua(vm)}\n\n.NET Traceback:\n{Catastrophe.StackTrace}"); #else SBubble.MyError($"Bubble.Graphics.Images.Grab(\"{assign}\")", Catastrophe.Message, $"{SBubble.TraceLua(vm)}"); #endif return("Il ya une catastrophe"); } }
public int Load(string name) { try { var mappath = $"Maps/Kthura/{name.Trim()}/"; BubConsole.WriteLine($"Loading Kthura map {mappath}", 180, 0, 255); if (!(SBubble.JCR.Exists($"{mappath}Objects") && SBubble.JCR.Exists($"{mappath}Data"))) { SBubble.MyError("Kthura LoadMap Error", $"Error finding the two required files for map {name}", $"Found({mappath}Objects) => {SBubble.JCR.Exists($"{mappath}Objects")}\nFound({mappath}Data) => {SBubble.JCR.Exists($"{mappath}Data")}"); return(0); } var KMap = Kthura.Load(SBubble.JCR, mappath, SBubble.JCR); BubConsole.WriteLine($"Kthura map {mappath} loaded", 180, 0, 255); return(Assign(KMap)); } catch (Exception Ellende) { if (JCR6.JERROR != "") { Crash(JCR6.JERROR); } else { Crash(Ellende); } BubConsole.CSay(Ellende.StackTrace); return(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, ""); } } }
private Bubble_Input(string state) { var script = QuickStream.StringFromEmbed("Input.lua"); SBubble.State(state).state["Bubble_Input"] = this; SBubble.DoNIL(state, "#macro MouseLeft 1\n#macro MouseRight 2\n#macro MouseCenter 3", "Mouse Button macros"); SBubble.State(state).DoString(script, "Input API header"); }
public void DoStateLua(string s, string script, string chunk = "LUA:DOSTATE") { try { SBubble.State(s).DoString(script, chunk); } catch (Exception Uitzondering) { SBubble.MyError($"LuaDoString(\"{s}\",\"{script}\",\"{chunk}\"):", Uitzondering.Message, ""); } }
private APIFlow(string state) { State = state; var s = SBubble.State(state).state; s["Bubble_Flow"] = this; SBubble.State(state).DoString(QuickStream.StringFromEmbed("Flow.lua"), "Flow Management"); }
public Bubble_Audio(string s) { var state = SBubble.State(s).state; var script = QuickStream.StringFromEmbed("Audio.nil"); state["Bubble_Audio"] = this; SBubble.DoNIL(s, script, "Audio init script"); }
public void DoStateNIL(string s, string script, string chunk = "NIL:DOSTATE") { try { SBubble.DoNIL(s, script, chunk); } catch (Exception Uitzondering) { SBubble.MyError($"NILDoString(\"{s}\",\"{script}\",\"{chunk}\"):", Uitzondering.Message, ""); } }
public static void LetsGo() { #region Install Error Manager, and the global engine! NALACore.Core.Window.Title = SBubble.Title; #endregion #region The base MonoGame stuff SBubble.AddInit(delegate(string v) { SBubble.State(v).DoString($"function {FlowManager.NOTHING}() end", "Alright move along, nothing to see here!"); }); SBubble.AddInit(BubbleConsole.StateInit); SBubble.AddInit(BubbleGraphics.InitGraphics); SBubble.AddInit(Bubble_Audio.Init); SBubble.AddInit(APIFlow.Init); SBubble.AddInit(BubbleSuperGlobal.Init); SBubble.AddInit(Bubble_Input.Init); SBubble.AddInit(Bubble_Save.Init); SBubble.AddInit(Bubble_Conf.Init); SBubble.AddInit(Bubble_GameJolt.Init); SBubble.AddInit(BubbleTimer.Init); SBubble.AddInit(Bubble_Swap.Init); #endregion #region Extras to use in savegames Bubble_Save.SaveXtra["RPGPARTY"] = delegate(UseJCR6.TJCRCreate j, string dir) { RPG.RPGSave(j, $"XTRA/{dir}"); }; Bubble_Save.LoadXtra["RPGPARTY"] = delegate(UseJCR6.TJCRDIR j, string dir) { RPG.RPGLoad(j, $"XTRA/{dir}"); return(true); }; Bubble_Save.SaveXtra["SWAP"] = Bubble_Swap.SwapSave; Bubble_Save.LoadXtra["SWAP"] = Bubble_Swap.SwapLoad; #endregion #region The stuff needed for NALA in particular // Own APIs for NIL and Lua //SBubble.AddInit(MapScriptAPI.API_Init); SBubble.AddInit(RPG_API.Init); // Kthura Init Kthura.SetDefaultTextureJCR(SBubble.JCR); // Textures are all in the same project KthuraDraw.DrawDriver = new KthuraDrawMonoGame(); // Tell Kthura to use the MonoGame Driver to display the map KthuraDrawMonoGame.CrashOnNoTex = delegate(string msg) { SBubble.MyError("Kthura Texture Error", msg, ""); }; // SBubble Kthura API SBubble.AddInit(KthuraBubble.KthuraBubble.Init); SBubble.AddInit(KthuraBubble.KthBlockAPI.Init); SBubble.AddInit(KthuraBubble.KthuraAbyssGenerator.Init); // TODO: API for TeddyBear // TODO: API for Swap Data Manager // TODO: API for RPGStat RPG.JCRSTORAGE = "lzma"; #endregion // Start init script FlowManager.StartInitFlow(); }
public void setPartyMember(int index, string tag) { if (index - 1 >= RPG.RPGParty.Length || index <= 0) { SBubble.MyError("RPG API Error", "Party Member index out of bounds", SBubble.TraceLua(statename)); return; } RPG.RPGParty[index - 1] = tag; }
static public void Init(string state) { me = new RPG_API(); var script = QuickStream.StringFromEmbed("RPG_API.nil"); SBubble.State(state).state["NALA_RPG"] = me; SBubble.DoNIL(state, script, "Link code RPG API"); me.statename = state; }
public void ComeToMe(int ID, string Lay, int x, int y) { try { var m = KthuraBubble.GetMap(ID); BubBlockMap.ComeToMe(FlowManager.GetHardFlow, m, Lay, x, y); } catch (Exception Crap) { SBubble.MyError("Kthura Blockmap Debug Error", Crap.Message, $"{ID}/{Lay}/({x},{y})"); } }
public void SetObjTex(int ID, string tag, string value) { try { var L = KMaps[ID].Layers[Layers[ID]]; L.FromTag(tag).Texture = value; } catch (Exception Calamity) { SBubble.MyError($"Setting texture of object {ID}:{tag}", Calamity.Message, LuaTrace); } }
public string getPartyMember(int index) { if (index - 1 >= RPG.RPGParty.Length || index <= 0) { SBubble.MyError("RPG API Error", "Party Member index out of bounds", SBubble.TraceLua(statename)); return(""); } return(RPG.RPGParty[index - 1]); }
static public void API_Init(string namestate) { var ret = new MapScriptAPI(); var state = SBubble.State(namestate).state; var script = QuickStream.StringFromEmbed("MapScriptAPI.nil"); state["NALAMSAPI"] = ret; SBubble.DoNIL(namestate, script, "MapScript init script"); }
static public void Init(string vm) { var nieuw = new BubbleTimer(); var state = SBubble.State(vm).state; nieuw.statename = vm; state["API_BUBBLE_TIMER"] = nieuw; state.DoString(Script, "Timer init script"); }
public bool HasTag(int id, string layer, string tag) { try { return(KMaps[id].Layers[layer].HasTag(tag)); } catch (Exception FuckYou) { SBubble.MyError($"BubbleKthura.Map[{id}].Layer[\"{layer}\"].HasTag(\"{tag}\"): ", FuckYou.Message, LuaTrace); return(false); } }
public string GetValue(string k) { try { InitSwap(); return(SwapMap[k]); } catch (Exception E) { SBubble.MyError($"Swap.Data[\"{k}\"]:", E.Message, SBubble.TraceLua(statename)); return("ERROR"); } }
public void LoadState(string s, string file) { s = s.ToUpper(); if (qstr.Prefixed(s, "FLOW_")) { throw new Exception("Non-Flow states may NOT be prefixed with FLOW_"); } SBubble.NewState(s, file); SBubble.State(s).state.DoString("if BUB_Load then BUB_Load() end"); }
public string GetObjTex(int ID, string tag) { try { var L = KMaps[ID].Layers[Layers[ID]]; return(L.FromTag(tag).Texture); } catch (Exception Calamity) { SBubble.MyError($"Getting texture of object {ID}:{tag}", Calamity.Message, ""); return("ERROR"); } }
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"); }
public void SetVisible(int ID, string tag, bool vis) { try { var L = KMaps[ID].Layers[Layers[ID]]; var O = L.FromTag(tag); O.Visible = vis; } catch (Exception VisWijf) { SBubble.MyError($"Kthura.SetVisible({ID},\"{tag}\",{vis}):", VisWijf.Message, LuaTrace); } }