Ejemplo n.º 1
0
    public ButtonTests()
    {
        _exchange = new EventExchange(new LogExchange());
        AssetMapping.GlobalIsThreadLocal = true;
        AssetMapping.Global.Clear()
        .RegisterAssetType(typeof(Base.Font), AssetType.Font)
        ;

        var jsonUtil   = new FormatJsonUtil();
        var font       = MockUniformFont.Font(AssetId.From(Base.Font.RegularFont));
        var modApplier = new MockModApplier()
                         .Add(new AssetId(AssetType.MetaFont, (ushort)new MetaFontId(false, FontColor.White)), font)
                         .AddInfo(AssetId.From(Base.Font.RegularFont), MockUniformFont.Info)
        ;

        var config = GameConfig.LoadLiteral(Encoding.UTF8.GetBytes(@"{ ""UI"": { ""ButtonDoubleClickIntervalSeconds"": 0.35 } }"), jsonUtil);

        _exchange
        .Register(config)
        .Attach(modApplier)
        .Attach(new AssetManager())
        .Attach(new SpriteManager())
        .Attach(new WindowManager {
            Resolution = (1920, 1080)
        })
Ejemplo n.º 2
0
    public void YesNoPromptTest()
    {
        AssetMapping.GlobalIsThreadLocal = true;
        AssetMapping.Global.Clear()
        .RegisterAssetType(typeof(Base.SystemText), AssetType.Text)
        .RegisterAssetType(typeof(Base.Font), AssetType.Font)
        ;

        var systemText = new Dictionary <TextId, string>
        {
            { Base.SystemText.MainMenu_DoYouReallyWantToQuit, "Do you really want to quit?" },
            { Base.SystemText.MsgBox_Yes, "Yes" },
            { Base.SystemText.MsgBox_No, "No" }
        };

        var ex  = new EventExchange(new LogExchange());
        var dm  = new DialogManager();
        var lm  = new LayoutManager();
        var mma = new MockModApplier()
                  .Add(new AssetId(AssetType.MetaFont, (ushort)new MetaFontId(false, FontColor.White)), MockUniformFont.Font(AssetId.From(Base.Font.RegularFont)))
                  .AddInfo(AssetId.From(Base.Font.RegularFont), MockUniformFont.Info)
        ;

        foreach (var kvp in systemText)
        {
            mma.Add(kvp.Key, kvp.Value);
        }

        ex
        .Attach(mma)
        .Attach(new AssetManager())
        .Attach(new SpriteManager())
        .Attach(new MockGameFactory())
        .Attach(new WordLookup())
        .Attach(new TextFormatter())
        .Attach(new TextManager())
        .Attach(new WindowManager {
            Resolution = (1920, 1080)
        })