Habit game Disable most mouse input when menu is open
This commit is contained in:
@@ -41,9 +41,13 @@
|
|||||||
(prop &mut :DebugLayer debugLayer null)
|
(prop &mut :DebugLayer debugLayer null)
|
||||||
|
|
||||||
(prop &mut t 1)
|
(prop &mut t 1)
|
||||||
|
(prop :FlxRect disableMouse (new FlxRect 0 0 0 0))
|
||||||
(method &override :Void update [:Float elapsed]
|
(method &override :Void update [:Float elapsed]
|
||||||
(super.update elapsed)
|
(super.update elapsed)
|
||||||
|
|
||||||
|
(if (windowIsShown)
|
||||||
|
(set FlxMouseControl.mouseZone disableMouse)
|
||||||
|
(set FlxMouseControl.mouseZone null))
|
||||||
|
|
||||||
(#when debug
|
(#when debug
|
||||||
(debugLayer.clear)
|
(debugLayer.clear)
|
||||||
@@ -60,17 +64,18 @@
|
|||||||
(unless z.isEmpty
|
(unless z.isEmpty
|
||||||
(debugLayer.drawFlxRect z FlxColor.RED)))))))
|
(debugLayer.drawFlxRect z FlxColor.RED)))))))
|
||||||
|
|
||||||
(when model.rewardFiles
|
(when model.rewardFiles
|
||||||
(let [zoom pieceCamera.zoom
|
(unless (windowIsShown)
|
||||||
scroll (pieceCamera.scroll.copyTo)]
|
(let [zoom pieceCamera.zoom
|
||||||
(pieceCamera.updateScrollWheelZoom elapsed 5)
|
scroll (pieceCamera.scroll.copyTo)]
|
||||||
(pieceCamera.updateMouseBorderControl elapsed KEYBOARD_SCROLL_SPEED 0.002 uiCamera)
|
(pieceCamera.updateScrollWheelZoom elapsed 5)
|
||||||
(when (or !(= zoom pieceCamera.zoom) !(scroll.equals pieceCamera.scroll))
|
(pieceCamera.updateMouseBorderControl elapsed KEYBOARD_SCROLL_SPEED 0.002 uiCamera)
|
||||||
(set save.data.zoom pieceCamera.zoom)
|
(when (or !(= zoom pieceCamera.zoom) !(scroll.equals pieceCamera.scroll))
|
||||||
(set save.data.scroll pieceCamera.scroll)
|
(set save.data.zoom pieceCamera.zoom)
|
||||||
(save.flush)))
|
(set save.data.scroll pieceCamera.scroll)
|
||||||
|
(save.flush))))
|
||||||
|
|
||||||
(when entryWindow
|
(when (and entryWindow !(tempWindowIsShown))
|
||||||
(when FlxG.keys.justPressed.ESCAPE
|
(when FlxG.keys.justPressed.ESCAPE
|
||||||
(if (entryWindow.isShown)
|
(if (entryWindow.isShown)
|
||||||
(entryWindow.hide)
|
(entryWindow.hide)
|
||||||
@@ -97,15 +102,15 @@
|
|||||||
|
|
||||||
// TODO provide a saner/configurable set of bindings to trigger these ui action functions
|
// TODO provide a saner/configurable set of bindings to trigger these ui action functions
|
||||||
{
|
{
|
||||||
(when FlxG.mouse.justPressedRight
|
|
||||||
(when draggingSprite
|
|
||||||
(draggingSprite.rotate 90)
|
|
||||||
(doFor s (recursivelyConnectedPieces draggingSprite)
|
|
||||||
(dictSet (the Map<Int,Float> save.data.storedAngles) (dictGet indexMap s) s.angle)
|
|
||||||
(dictSet (the Map<Int,FlxPoint> save.data.storedOrigins) (dictGet indexMap s) s.origin))
|
|
||||||
(save.flush)))
|
|
||||||
|
|
||||||
|
(unless (windowIsShown)
|
||||||
|
(when FlxG.mouse.justPressedRight
|
||||||
|
(when draggingSprite
|
||||||
|
(draggingSprite.rotate 90)
|
||||||
|
(doFor s (recursivelyConnectedPieces draggingSprite)
|
||||||
|
(dictSet (the Map<Int,Float> save.data.storedAngles) (dictGet indexMap s) s.angle)
|
||||||
|
(dictSet (the Map<Int,FlxPoint> save.data.storedOrigins) (dictGet indexMap s) s.origin))
|
||||||
|
(save.flush))))
|
||||||
|
|
||||||
(method startAdding [:EntryType type]
|
(method startAdding [:EntryType type]
|
||||||
(set typeAdding type)
|
(set typeAdding type)
|
||||||
@@ -142,6 +147,20 @@
|
|||||||
|
|
||||||
(prop &mut :FlxSave save null)
|
(prop &mut :FlxSave save null)
|
||||||
(prop &mut :SimpleWindow entryWindow null)
|
(prop &mut :SimpleWindow entryWindow null)
|
||||||
|
// TODO add other windows and add them to the windowIsShown and tempWindowIsShown lists
|
||||||
|
|
||||||
|
(method windowIsShown []
|
||||||
|
(doFor window [entryWindow]
|
||||||
|
(when (and window (window.isShown))
|
||||||
|
(return true)))
|
||||||
|
false)
|
||||||
|
|
||||||
|
(method tempWindowIsShown []
|
||||||
|
(doFor window []
|
||||||
|
(when (and window (window.isShown))
|
||||||
|
(return true)))
|
||||||
|
false)
|
||||||
|
|
||||||
(prop &mut :FlxTypedGroup<FlxText> logTexts (new FlxTypedGroup))
|
(prop &mut :FlxTypedGroup<FlxText> logTexts (new FlxTypedGroup))
|
||||||
(prop &mut :FlxKeyShortcutHandler<Entry> shortcutHandler null)
|
(prop &mut :FlxKeyShortcutHandler<Entry> shortcutHandler null)
|
||||||
|
|
||||||
|
|||||||
@@ -80,14 +80,22 @@ class DragToSelectPlugin extends FlxBasic {
|
|||||||
var camera = dragState.camera;
|
var camera = dragState.camera;
|
||||||
if (camera == null) camera = FlxG.camera;
|
if (camera == null) camera = FlxG.camera;
|
||||||
|
|
||||||
|
// If FlxMouseControl has a mouseZone enabled, respect it
|
||||||
|
var mousePos = FlxG.mouse.getWorldPosition(camera);
|
||||||
|
if (FlxMouseControl.mouseZone != null && !FlxMouseControl.mouseZone.containsPoint(mousePos)) {
|
||||||
|
dragState.firstCorner = null;
|
||||||
|
dragState.secondCorner = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// have to skip a frame after justPressed, so KissExtendedSprites
|
// have to skip a frame after justPressed, so KissExtendedSprites
|
||||||
// can get first access to the mouse input
|
// can get first access to the mouse input
|
||||||
if (FlxMouseControl.dragTarget == null) {
|
if (FlxMouseControl.dragTarget == null) {
|
||||||
if (wasJustPressed && FlxMouseControl.clickTarget == null) {
|
if (wasJustPressed && FlxMouseControl.clickTarget == null) {
|
||||||
deselectSprites();
|
deselectSprites();
|
||||||
dragState.firstCorner = FlxG.mouse.getWorldPosition(camera);
|
dragState.firstCorner = mousePos;
|
||||||
}
|
}
|
||||||
dragState.secondCorner = FlxG.mouse.getWorldPosition(camera);
|
dragState.secondCorner = mousePos;
|
||||||
if (dragState.firstCorner != null && dragState.selectedSprites.length == 0) {
|
if (dragState.firstCorner != null && dragState.selectedSprites.length == 0) {
|
||||||
var rounded1 = dragState.firstCorner.copyTo();
|
var rounded1 = dragState.firstCorner.copyTo();
|
||||||
var rounded2 = dragState.secondCorner.copyTo();
|
var rounded2 = dragState.secondCorner.copyTo();
|
||||||
|
|||||||
Reference in New Issue
Block a user