Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent soft-locking in RPGInterface demo (Fixes #267) #327

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions UserInterface/RPGInterface/assets/xml/state_default.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@
</radio_group>
</group>
<group id="tab_2">
<checkbox x="10" y="10"label="$MENU_THING_1">
<checkbox x="10" y="10" label="$MENU_THING_1">
<param type="string" value="thing 1"/>
</checkbox>
<checkbox x="10" y="40"label="$MENU_THING_2">
<checkbox x="10" y="40" label="$MENU_THING_2">
<param type="string" value="thing 2"/>
</checkbox>
</group>
Expand Down
43 changes: 43 additions & 0 deletions UserInterface/RPGInterface/source/Popup_Default.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import flixel.addons.ui.FlxUI;
import flixel.addons.ui.interfaces.IFlxUIState;
import flixel.addons.ui.FlxUITypedButton;
import flixel.addons.ui.interfaces.IFlxUIWidget;
import flixel.addons.ui.FlxUIPopup;

class Popup_Default extends FlxUIPopup
{
override function getEvent(id:String, sender:IFlxUIWidget, data:Dynamic, ?eventParams:Array<Dynamic>)
{
if (eventParams == null)
{
if (params != null)
{
eventParams = [];
}
}
if (params != null)
{
eventParams = eventParams.concat(params);
}

switch (id)
{
case FlxUITypedButton.CLICK_EVENT:
if (eventParams != null)
{
var buttonAmount:Int = Std.int(eventParams[0]); // 0 is Yes, 1 is No and 2 is Cancel
if ((_parentState is IFlxUIState))
{
// This fixes a bug where the event was being sent to this popup rather than the state that created it
castParent().getEvent(FlxUIPopup.CLICK_EVENT, this, buttonAmount, eventParams);
}
else
{
// This is a generic fallback in case something goes wrong
FlxUI.event(FlxUIPopup.CLICK_EVENT, this, buttonAmount, eventParams);
}
close();
}
}
}
}
4 changes: 2 additions & 2 deletions UserInterface/RPGInterface/source/State_DefaultTest.hx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class State_DefaultTest extends FlxUIState
{
case "back": FlxG.switchState(new State_Title());
case "popup":
var popup:FlxUIPopup = new FlxUIPopup(); // create the popup
var popup:FlxUIPopup = new Popup_Default(); // create the popup
popup.quickSetup // set it up
(Main.tongue.get("$POPUP_DEMO_2_TITLE", "ui"), // title text
Main.tongue.get("$POPUP_DEMO_2_BODY", "ui"), // body text
Expand All @@ -54,4 +54,4 @@ class State_DefaultTest extends FlxUIState
}
}
}
}
}
Loading