public LMessage(LTexture formImage, int x, int y, int width, int height) : base(x, y, width, height) { this.animation = new Animation(); if (formImage == null) { this.SetBackground(new LTexture(width, height, true)); this.SetAlpha(0.3F); } else { this.SetBackground(formImage); if (width == -1) { width = formImage.GetWidth(); } if (height == -1) { height = formImage.GetHeight(); } } this.print = new Print(GetLocation(), messageFont, width, height); if (XNAConfig.IsActive()) { this.SetTipIcon(XNAConfig.LoadTex(LSystem.FRAMEWORK_IMG_NAME + "creese.png")); } this.totalDuration = 80; this.customRendering = true; this.SetWait(false); this.SetElastic(true); this.SetLocked(true); this.SetLayer(100); }
public EmulatorButtons(EmulatorListener el, int w, int h, float scale) { this.emulatorListener = el; this.dpad = XNAConfig.LoadTexture("e1.png"); this.buttons = XNAConfig.LoadTexture("e2.png"); this.width = w; this.height = h; if (scale <= 1f) { this.up = new EmulatorButton(dpad, 40, 40, 40, 0, true, 60, 60); this.left = new EmulatorButton(dpad, 40, 40, 0, 40, true, 60, 60); this.right = new EmulatorButton(dpad, 40, 40, 80, 40, true, 60, 60); this.down = new EmulatorButton(dpad, 40, 40, 40, 80, true, 60, 60); this.triangle = new EmulatorButton(buttons, 48, 48, 48, 0, true, 68, 68); this.square = new EmulatorButton(buttons, 48, 48, 0, 48, true, 68, 68); this.circle = new EmulatorButton(buttons, 48, 48, 96, 48, true, 68, 68); this.cancel = new EmulatorButton(buttons, 48, 48, 48, 96, true, 68, 68); } else { this.up = new EmulatorButton(dpad, 40, 40, 40, 0, true, (int)(60 * scale), (int)(60 * scale)); this.left = new EmulatorButton(dpad, 40, 40, 0, 40, true, (int)(60 * scale), (int)(60 * scale)); this.right = new EmulatorButton(dpad, 40, 40, 80, 40, true, (int)(60 * scale), (int)(60 * scale)); this.down = new EmulatorButton(dpad, 40, 40, 40, 80, true, (int)(60 * scale), (int)(60 * scale)); this.triangle = new EmulatorButton(buttons, 48, 48, 48, 0, true, (int)(68 * scale), (int)(68 * scale)); this.square = new EmulatorButton(buttons, 48, 48, 0, 48, true, (int)(68 * scale), (int)(68 * scale)); this.circle = new EmulatorButton(buttons, 48, 48, 96, 48, true, (int)(68 * scale), (int)(68 * scale)); this.cancel = new EmulatorButton(buttons, 48, 48, 48, 96, true, (int)(68 * scale), (int)(68 * scale)); } if (dpad != null) { dpad.Dispose(); dpad = null; } if (buttons != null) { buttons.Dispose(); buttons = null; } this.visible = true; this.SetLocation(0, 0); }
public virtual Stream GetInputStream() { try { if (ins0 != null) { return(ins0); } if (classLoader == null) { return(ins0 = Resources.OpenStream(path)); } else { try { return(ins0 = XNAConfig.LoadStream(path)); } catch { return(ins0 = Resources.ApplicationResourceStream(new Uri(path))); } } } catch (Exception e) { Loon.Utils.Debug.Log.Exception(e); } return(null); }
public RainKernel(int n, int w, int h) { id = n; rain = XNAConfig.LoadTex(LSystem.FRAMEWORK_IMG_NAME + "rain_" + n + ".png"); rainWidth = rain.GetWidth(); rainHeight = rain.GetHeight(); width = w; height = h; offsetX = 0; offsetY = (5 - n) * 30 + 75 + MathUtils.Random() * 15; }
public SnowKernel(int n, int w, int h) { snow = XNAConfig .LoadTex(LSystem.FRAMEWORK_IMG_NAME + "snow_" + n + ".png"); snowWidth = snow.GetWidth(); snowHeight = snow.GetHeight(); width = w; height = h; offsetX = 0; offsetY = n * 0.6f + 1.9f + MathUtils.Random() * 0.2f; speed = MathUtils.Random(); }
public PetalKernel(int n, int w, int h) { id = n; sakura = XNAConfig.LoadTexture("sakura_" + n + ".png"); sakuraWidth = sakura.GetWidth(); sakuraHeight = sakura.GetHeight(); width = w; height = h; offsetX = 0; offsetY = n * 0.6f + 1.9f + MathUtils.Random() * 0.2f; speed = MathUtils.Random(); }
/// <summary> /// 初始化事件 /// </summary> /// <param name="plus"></param> public void OnMain(LSilverlightPlus plus) { //加载LGame默认资源(不进行此操作,LGame内置的模拟按钮之类功能无法使用) XNAConfig.Load("content/loon.def"); //加载字体文件(此处是预编译好的xnb文件,也可以加载标准Content下的) plus.XNAFont = new LFont("content", "black", 0, 20); //设定启动参数 LSetting setting = new LSetting(); setting.fps = 60; setting.width = 480; setting.height = 320; setting.showFPS = true; setting.landscape = false; //注册初始Screen plus.Register(setting, typeof(ScreenTest)); }
public override void OnMain() { //加载LGame默认资源(不进行此操作,LGame内置的模拟按钮之类功能无法使用) XNAConfig.Load("assets/loon.def"); //加载字体文件(此处是预编译好的xnb文件,也可以加载Content下的) XNAFont = new LFont("assets", "black", 0, 20); //注册AD监听(标准XNA事件监听) SetXNAListener(new ADListener()); //设定启动参数 LSetting setting = new LSetting(); setting.fps = 60; setting.width = 480; setting.height = 320; setting.showFPS = true; setting.landscape = true; //注册初始Screen Register(setting, typeof(ScreenTest)); }
static void LoadResToMemory() { Stream stream = null; ArrayByte resStream = null; try { stream = XNAConfig.LoadStream(LSystem.FRAMEWORK_IMG_NAME + "font.zip"); resStream = new ArrayByte(new GZipInputStream(stream), ArrayByte.BIG_ENDIAN); realsize = resStream.ReadByte(); offy = resStream.ReadByte(); fontSpace = (realsize + offy) * 2; if (realsize > 0x10) { fontSpace *= 2; } int num = resStream.ReadInt(); int num2 = resStream.ReadByte(); byte[] bufferData = new byte[resStream.Available()]; resStream.Read(bufferData); fontData = bufferData; } catch (Exception) { fontData = null; } finally { if (stream != null) { stream.Dispose(); stream.Close(); stream = null; } if (resStream != null) { resStream = null; } } }
public LSelect(LTexture formImage, int x, int y, int width, int height) : base(x, y, width, height) { if (formImage == null) { this.SetBackground(new LTexture(width, height, true, Loon.Core.Graphics.Opengl.LTexture.Format.SPEED)); this.SetAlpha(0.3F); } else { this.SetBackground(formImage); } this.customRendering = true; this.selectFlag = 1; this.tmpOffset = -(width / 10); this.delay = new LTimer(150); this.autoAlpha = 0.25F; this.isAutoAlpha = true; this.SetCursor(XNAConfig.LoadTex(LSystem.FRAMEWORK_IMG_NAME + "creese.png")); this.SetElastic(true); this.SetLocked(true); this.SetLayer(100); }
public LSelect(LTexture formImage, int x, int y, int width, int height) : base(x, y, width, height) { if (formImage == null) { this.SetBackground(new LTexture(width, height, true)); this.SetAlpha(0.3F); } else { this.SetBackground(formImage); } this.customRendering = true; this.selectFlag = 1; this.tmpOffset = -(width / 10); this.delay = new LTimer(150); this.autoAlpha = 0.25F; this.isAutoAlpha = true; this.SetCursor(XNAConfig.LoadTexture("creese.png")); this.SetElastic(true); this.SetLocked(true); this.SetLayer(100); }
public override void OnMain() { //加载LGame默认资源(不进行此操作,LGame内置的模拟按钮之类功能无法使用) XNAConfig.Load("content/loon.def"); //加载字体文件(此处是预编译好的xnb文件 PS:当自定义资源文件夹命名为Content时, //打包后会自动和标准的Content文件夹合并,这里做个演示。另,Windows系统不区分文件 //名大小写) XNAFont = new LFont("content", "black", 0, 20); //注册AD监听(标准XNA事件监听) SetXNAListener(new ADListener()); //设定启动参数 LSetting setting = new LSetting(); setting.fps = 60; setting.width = 480; setting.height = 320; setting.showFPS = true; setting.landscape = false; //注册初始Screen Register(setting, typeof(ScreenTest)); }
public FlagImage(LInfo i) { this.info = i; // 读取基础标记 if (page == null || (page != null && page.isClose)) { if (page != null) { page.Destroy(); page = null; } page = XNAConfig.LoadTexture("page.png"); } if (line == null || (line != null && line.isClose)) { if (line != null) { line.Destroy(); line = null; } line = XNAConfig.LoadTexture("line.png"); } texture = page; }
public LPad(int x, int y, float scale) : this(x, y, XNAConfig.LoadTexture("pad_ui_back.png"), XNAConfig.LoadTexture("pad_ui_fore.png"), XNAConfig.LoadTexture("pad_ui_dot.png"), scale) { }
/// <summary> /// 尝试读取数据流 /// </summary> /// <param name="resName"></param> /// <returns></returns> public static System.IO.Stream OpenStream(string resName) { if (resName.IndexOf("/") == -1 && FileUtils.GetExtension(resName).Length == 0) { resName = "Content/" + resName; } Stream resource = StrRes(resName); if (resource != null) { return(resource); } //尝试读取XAP中文件(Content类型) System.IO.Stream stream = null; try { stream = TitleContainer.OpenStream(resName); } catch { try { if (stream == null) { stream = XNAConfig.LoadStream(resName); } } catch (Exception) { if (stream == null) { //尝试读取DLL中文件(Resource类型) Uri pathUri = new Uri("/" + JavaRuntime.GetAssemblyName() + ";component/" + resName, UriKind.RelativeOrAbsolute); stream = ApplicationResourceStream(pathUri); } } } if (stream == null) { //尝试读取标准路径数据 try { stream = new System.IO.FileStream(resName, System.IO.FileMode.Open); } catch { //尝试读取封闭空间中数据 try { System.IO.IsolatedStorage.IsolatedStorageFile store = System.IO.IsolatedStorage.IsolatedStorageFile.GetUserStoreForApplication(); stream = store.OpenFile(resName, System.IO.FileMode.Open); } catch (Exception ex) { Loon.Utils.Debugging.Log.Exception(ex); Loon.Utils.Debugging.Log.DebugWrite('\n' + resName + " file not found !"); } } } return(stream); }
public LControl(int x, int y, int bw, int bh, int dw, int dh) : this(x, y, XNAConfig.LoadTex(LSystem.FRAMEWORK_IMG_NAME + "control_base.png"), XNAConfig.LoadTex( LSystem.FRAMEWORK_IMG_NAME + "control_dot.png"), bw, bh, dw, dh) { }
static void LoadResToCache() { string loon_default_font = "lfcache"; IsolatedStorageFile isoStorage = IsolatedStorageFile.GetUserStoreForApplication(); if (!isoStorage.FileExists(loon_default_font)) { IsolatedStorageFileStream outStream = isoStorage.CreateFile(loon_default_font); Stream gzip = null; try { gzip = new GZipInputStream(XNAConfig.LoadStream(LSystem.FRAMEWORK_IMG_NAME + "font.zip")); byte[] buffer = new byte[4096]; int charsRead; while ((charsRead = gzip.Read(buffer, 0, buffer.Length)) != 0) { outStream.Write(buffer, 0, charsRead); } outStream.Flush(); if (gzip != null) { gzip.Close(); gzip.Dispose(); gzip = null; } buffer = null; } catch (Exception) { if (outStream != null) { outStream.Close(); outStream.Dispose(); outStream = null; } if (gzip != null) { gzip.Close(); gzip.Dispose(); gzip = null; } IsolatedStorageFile.GetUserStoreForApplication().DeleteFile(loon_default_font); } finally { if (outStream != null) { outStream.Close(); outStream = null; } } } Stream ins = null; try { ins = isoStorage.OpenFile(loon_default_font, FileMode.Open); DataInputStream resStream = new DataInputStream(ins); realsize = resStream.ReadUnsignedByte(); offy = resStream.ReadByte(); fontSpace = (realsize + offy) * 2; if (realsize > 0x10) { fontSpace *= 2; } int num = resStream.ReadInt(); int num2 = resStream.ReadByte(); byte[] bufferData = new byte[resStream.Available()]; resStream.Read(bufferData); fontData = bufferData; if (resStream != null) { resStream.Close(); resStream = null; } } catch (Exception) { fontData = null; if (ins != null) { ins.Close(); ins.Dispose(); ins = null; } LoadResToMemory(); } finally { if (ins != null) { ins.Close(); ins.Dispose(); ins = null; } } }
public EmulatorButtons(EmulatorListener el, int w, int h, float scale) { this.emulatorListener = el; if (pack == null) { pack = new LTexturePack(); pack.PutImage(XNAConfig.LoadTex(LSystem.FRAMEWORK_IMG_NAME + "e1.png")); pack.PutImage(XNAConfig.LoadTex(LSystem.FRAMEWORK_IMG_NAME + "e2.png")); pack.Pack(Loon.Core.Graphics.Opengl.LTexture.Format.LINEAR); } RectBox.Rect2i bounds = pack.GetEntry(0).getBounds(); this.dpad = new LTextureRegion(pack.GetTexture(), bounds.left, bounds.top, bounds.right, bounds.bottom); bounds = pack.GetEntry(1).getBounds(); this.buttons = new LTextureRegion(pack.GetTexture(), bounds.left, bounds.top, bounds.right, bounds.bottom); this.width = w; this.height = h; if (scale <= 0f) { this.up = new EmulatorButton(dpad, 40, 40, 40, 0, true, 60, 60); this.left = new EmulatorButton(dpad, 40, 40, 0, 40, true, 60, 60); this.right = new EmulatorButton(dpad, 40, 40, 80, 40, true, 60, 60); this.down = new EmulatorButton(dpad, 40, 40, 40, 80, true, 60, 60); this.triangle = new EmulatorButton(buttons, 48, 48, 48, 0, true, 68, 68); this.square = new EmulatorButton(buttons, 48, 48, 0, 48, true, 68, 68); this.circle = new EmulatorButton(buttons, 48, 48, 96, 48, true, 68, 68); this.cancel = new EmulatorButton(buttons, 48, 48, 48, 96, true, 68, 68); } else { this.up = new EmulatorButton(dpad, 40, 40, 40, 0, true, (int)(60 * scale), (int)(60 * scale)); this.left = new EmulatorButton(dpad, 40, 40, 0, 40, true, (int)(60 * scale), (int)(60 * scale)); this.right = new EmulatorButton(dpad, 40, 40, 80, 40, true, (int)(60 * scale), (int)(60 * scale)); this.down = new EmulatorButton(dpad, 40, 40, 40, 80, true, (int)(60 * scale), (int)(60 * scale)); this.triangle = new EmulatorButton(buttons, 48, 48, 48, 0, true, (int)(68 * scale), (int)(68 * scale)); this.square = new EmulatorButton(buttons, 48, 48, 0, 48, true, (int)(68 * scale), (int)(68 * scale)); this.circle = new EmulatorButton(buttons, 48, 48, 96, 48, true, (int)(68 * scale), (int)(68 * scale)); this.cancel = new EmulatorButton(buttons, 48, 48, 48, 96, true, (int)(68 * scale), (int)(68 * scale)); } this.up._monitor = new up_monitor(el); this.left._monitor = new left_monitor(el); this.right._monitor = new right_monitor(el); this.down._monitor = new down_monitor(el); this.triangle._monitor = new triangle_monitor(el); this.square._monitor = new square_monitor(el); this.circle._monitor = new circle_monitor(el); this.cancel._monitor = new cancel_monitor(el); if (dpad != null) { dpad.Dispose(); dpad = null; } if (buttons != null) { buttons.Dispose(); buttons = null; } this.visible = true; this.SetLocation(0, 0); }
public LControl(int x, int y, int bw, int bh, int dw, int dh) : this(x, y, XNAConfig.LoadTexture( "control_base.png"), XNAConfig.LoadTexture("control_dot.png"), bw, bh, dw, dh) { }
public LPad(int x, int y, float scale) : this(x, y, XNAConfig.LoadTex(LSystem.FRAMEWORK_IMG_NAME + "pad_ui_back.png"), XNAConfig.LoadTex(LSystem.FRAMEWORK_IMG_NAME + "pad_ui_fore.png"), XNAConfig.LoadTex(LSystem.FRAMEWORK_IMG_NAME + "pad_ui_dot.png"), scale) { }