public LPad(int x, int y, LTexturePack p, float scale) : base(x, y, (int)(p.GetEntry("fore").Width() * scale), (int)(p .GetEntry("fore").Height() * scale)) { this.offsetX = 6 * scale; this.offsetY = 6 * scale; this.pack = p; this.dotWidth = (int)(p.GetEntry("dot").Width() * scale); this.dotHeight = (int)(p.GetEntry("dot").Height() * scale); this.baseWidth = (int)(p.GetEntry("fore").Width() * scale); this.baseHeight = (int)(p.GetEntry("fore").Height() * scale); this.backWidth = (int)(p.GetEntry("back").Width() * scale); this.backHeight = (int)(p.GetEntry("back").Height() * scale); this.centerX = (baseWidth - dotWidth) / 2 + offsetX; this.centerY = (baseHeight - dotHeight) / 2 + offsetY; this.scale_pad = scale; p.SetFormat(Loon.Core.Graphics.Opengl.LTexture.Format.LINEAR); }
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); }