Skip to content

Commit

Permalink
fix: set stage focus when unpausing the game if stage focus was lost …
Browse files Browse the repository at this point in the history
…after interacting with the game's option menus, this was resulting in keyboard events not working
  • Loading branch information
Notexe committed Mar 17, 2024
1 parent 2dabd58 commit bdaab3f
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 0 deletions.
46 changes: 46 additions & 0 deletions content/chunk0/SimpleKeyEventHelper.entity.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
"m_sModifierKeyName": { "type": "ZString", "value": "None" },
"m_sKeyName": { "type": "ZString", "value": "" }
},
"events": {
"onFocusAdded": { "SetTrue": ["cafea42ab80074e5"] },
"onFocusRemoved": { "SetFalse": ["cafea42ab80074e5"] }
},
"outputCopying": {
"Pressed": { "Pressed": ["cafe099752f99e2c"] },
"Down": { "Down": ["cafe099752f99e2c"] },
Expand All @@ -49,6 +53,48 @@
"factory": "[modules:/zuicontroltreeentity.class].pc_entitytype",
"blueprint": "[modules:/zuicontroltreeentity.class].pc_entityblueprint",
"properties": { "m_pRootControlEntity": { "type": "SEntityTemplateReference", "value": "cafe457f1b485c64" } }
},
"cafe9eba71ce2ad7": {
"parent": "cafe099752f99e2c",
"name": "MenuCondition",
"factory": "[modules:/zmenucondition.class].pc_entitytype",
"blueprint": "[modules:/zmenucondition.class].pc_entityblueprint",
"properties": { "m_bAnyPausingMenu": { "type": "bool", "value": true } }
},
"cafea42ab80074e5": {
"parent": "cafe099752f99e2c",
"name": "Has focus",
"factory": "[assembly:/_pro/design/logic/valuebool.template?/valuebool_basic.entitytemplate].pc_entitytype",
"blueprint": "[assembly:/_pro/design/logic/valuebool.template?/valuebool_basic.entitytemplate].pc_entityblueprint",
"properties": { "m_bValue": { "type": "bool", "value": false } }
},
"cafe7b048464ae75": {
"parent": "cafe099752f99e2c",
"name": "ValueBool_Operation",
"factory": "[assembly:/_pro/design/logic/valuebool.template?/valuebool_operation.entitytemplate].pc_entitytype",
"blueprint": "[assembly:/_pro/design/logic/valuebool.template?/valuebool_operation.entitytemplate].pc_entityblueprint",
"properties": {
"m_aValues": {
"type": "TArray<SEntityTemplateReference>",
"value": ["cafe311535ba0dbc", "cafe1e0d0d098557"]
},
"m_eEvaluation": { "type": "ZValueBool_Operation_Signal.EEvaluationType", "value": "ALL" }
},
"events": { "OnTrue": { "SetFocus": ["cafe457f1b485c64"] } }
},
"cafe311535ba0dbc": {
"parent": "cafea42ab80074e5",
"name": "Has lost focus",
"factory": "[modules:/zinvertedcondition.class].pc_entitytype",
"blueprint": "[modules:/zinvertedcondition.class].pc_entityblueprint",
"properties": { "m_rCondition": { "type": "SEntityTemplateReference", "value": "cafea42ab80074e5" } }
},
"cafe1e0d0d098557": {
"parent": "cafe9eba71ce2ad7",
"name": "Has unpaused",
"factory": "[modules:/zinvertedcondition.class].pc_entitytype",
"blueprint": "[modules:/zinvertedcondition.class].pc_entityblueprint",
"properties": { "m_rCondition": { "type": "SEntityTemplateReference", "value": "cafe9eba71ce2ad7" } }
}
},
"propertyOverrides": [],
Expand Down
Binary file modified content/chunk0/scaleform/001598DB8D4DC9DB.GFXF
Binary file not shown.
Binary file modified content/chunk0/scaleform/00FDD03F03A3CAB7.UICB
Binary file not shown.
Binary file modified source/bin/SimpleKeyEventHelper.swf
Binary file not shown.
22 changes: 22 additions & 0 deletions source/src/simplekeyeventhelper/SimpleKeyEventHelper.as
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class SimpleKeyEventHelper extends BaseControl {

public function SimpleKeyEventHelper() {
addEventListener(Event.ADDED_TO_STAGE, onAdded);
addEventListener(Event.REMOVED_FROM_STAGE, onRemoved);
}

public function onSetData(object:Object):void {
Expand All @@ -31,6 +32,19 @@ public class SimpleKeyEventHelper extends BaseControl {
private function onAdded(event:Event):void {
if (m_enabled) {
addKeyListeners();
Send_onFocusAdded();
}
}

private function onRemoved(event:Event):void {
if (m_enabled) {
Send_onFocusRemoved();
}
}

public function SetFocus():void {
if (m_enabled) {
stage.focus = this;
}
}

Expand Down Expand Up @@ -128,5 +142,13 @@ public class SimpleKeyEventHelper extends BaseControl {
sendEvent("Up");
}

public function Send_onFocusRemoved():void {
sendEvent("onFocusRemoved");
}

public function Send_onFocusAdded():void {
sendEvent("onFocusAdded");
}

}
}

0 comments on commit bdaab3f

Please sign in to comment.