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

FlxBasePreloader: improve the sitelock failure notice #1994

Merged
merged 2 commits into from
Apr 26, 2017

Conversation

seraku24
Copy link
Contributor

@seraku24 seraku24 commented Nov 6, 2016

The existing sitelock failure notice is, well, a little lackluster. Unfortunately, the sitelock functionality within the FlxBasePreloader class is not as easily modified, requiring the programmer to duplicate parts of the logic not dealing with the visuals.

I decided the improvements I made for my own uses should be shared with the world, so here is a PR for including an updated version of the sitelock failure notice. And as pictures are nice, here is how the new default failure notice looks:

haxeflixel-sitelockfailurenotice-default

As the underlying logic has been reorganized to address the issues mentioned above and several helper functions have been added to aid in the creation of the visual elements, here is a code snippet showing a sample customization in action:

class Preloader extends FlxBasePreloader
{
    public function new():Void {
        super(0, [ "http://placeholder.domain.test/path/document.html" ]);

        siteLockTitleText = "Oops!";
        siteLockBodyText = "Well, it looks like somebody went and did a very bad and naughty thing.\n\n"
            + "Why not try heading over to the following website to play this game?";
    }

    override private function createSiteLockFailureScreen():Void {
        addChild(createSiteLockFailureBackground(0xeeaa33, 0xbb5533));
        addChild(createSiteLockFailureIcon(0xffcc33, 0.5));
        addChild(createSiteLockFailureText(60));
    }

    override private function adjustSiteLockTextFields(titleText:TextField, bodyText:TextField, hyperlinkText:TextField):Void {
        titleText.setTextFormat(new TextFormat("Cambria", 40, 0xffcc33, true, true));
        bodyText.setTextFormat(new TextFormat("Cambria", 25, 0x112244));
        hyperlinkText.setTextFormat(new TextFormat("Consolas", 20, 0xffcc33));
        hyperlinkText.background = true;
        hyperlinkText.backgroundColor = 0x112244;
    }

    // . . .
}

haxeflixel-sitelockfailurenotice-customized

}

private function createSiteLockFailureBackground(innerColor:UInt, outerColor:UInt):Shape
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code uses a mix of tabs and spaces. Technically haxe-checkstyle / CodeClimate should catch this, but I've had issues with that in the past IIRC... :/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it's because of HaxeCheckstyle/haxe-checkstyle#278.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about this. VSCode normally does the right thing by matching the formatting of the file you are editing. However, I use spaces in my own code, so any new files that I write will use spaces instead of tabs. Since I had to do a big copy-paste job for this one, the spaces I normally used leaked in here. I thought I caught that and normalized it, but I think that may have only been for a few lines here and there.

Copy link
Contributor

@gamedevsam gamedevsam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good change, but please add indication on how users can override default values.

*/
public static inline var LOCAL:String = #if flash "local" #else "localhost" #end;

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the extra lines?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extra lines? Are you referring to the whitespace normalization? If so, there should not be any "extra" lines. I will of course double-check once I get this branch rebased to address the changes you requested below as well as the conflicts due to the PR's old age.


/**
* The title text to display on the sitelock failure screen.
* NOTE: This string should be reviewed for accuracy and may need to be localized.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provide hint on how user can override this text, ex:

* To override this variable, create a new preloader class that extends FlxBasePreloader, and override the default value in new function before you call super();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added clarification on how to customize as well as a providing a simple example.


/**
* The body text to display on the sitelock failure screen.
* NOTE: This string should be reviewed for accuracy and may need to be localized.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

@seraku24 seraku24 force-pushed the seraku24-improve-sitelock branch from 74617c2 to fb461c7 Compare April 24, 2017 16:31
@gamedevsam
Copy link
Contributor

@Gama11 any reservations about this change?

@Gama11
Copy link
Member

Gama11 commented Apr 24, 2017

Can we add @since tags to new API? Also wrap class names in docs etc in backticks for markdown formatting.

More generally, this seems like a lot of effort for a fairly niche / little-used feature, but hey, it's already here now, and it looks nice. :)

addChild(createSiteLockFailureText(30));
}

private function createSiteLockFailureBackground(innerColor:UInt, outerColor:UInt):Shape
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason not to use FlxColor for colors?

Copy link
Contributor Author

@seraku24 seraku24 Apr 24, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. I'm fairly certain FlxColor would work. I most likely wrote it this way since the underlying graphics APIs expect UInt.

@seraku24
Copy link
Contributor Author

@Gama11 What do I need to put in for a @since tag? Just 4.2.0 (ignoring the revision)?

@Gama11
Copy link
Member

Gama11 commented Apr 24, 2017

4.3.0 actually, since that will be the next release. Example:

https://github.com/HaxeFlixel/flixel/blob/dev/flixel/FlxCamera.hx#L1529

Improved the visuals of the failure notice.
Revised the default failure notice text.
Enabled easy customization of the failure notice text and formatting.
Provide example for customizing title/body text.
Added since tags for 4.3.0.
Changed UInt to FlxColor for color-based arguments.

Fix Travis build break against Haxe 3.2.0.
An Array<Int> is not being converted to a Vector<Float> when compiled with the older version of Haxe.  Making the first element an explicit floating-point value will force the type to Array<Float> which, hopefully, should convert as expected.
@seraku24 seraku24 force-pushed the seraku24-improve-sitelock branch from 0d091bf to 593d33d Compare April 24, 2017 21:57
@seraku24
Copy link
Contributor Author

seraku24 commented Apr 24, 2017

Okay, that should do it. Thanks, @Gama11 and @gamedevsam for all the feedback and help.

@Gama11 Gama11 changed the title Improving the sitelock failure notice. FlxBasePreloader: improve the sitelock failure notice Apr 26, 2017
@Gama11
Copy link
Member

Gama11 commented Apr 26, 2017

This doesn't really affect #2055 (for better or worse), so I'll go ahead and merge it.

Definitely looks a lot nicer than before, thanks!

@Gama11 Gama11 merged commit 6050040 into HaxeFlixel:dev Apr 26, 2017
@seraku24 seraku24 deleted the seraku24-improve-sitelock branch April 26, 2017 21:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants