NodeTitle.cs :  » Game » SokoSolve-Sokoban » SokoSolve » Core » UI » Nodes » Specific » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Game » SokoSolve Sokoban 
SokoSolve Sokoban » SokoSolve » Core » UI » Nodes » Specific » NodeTitle.cs
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using SokoSolve.Common.Math;
using SokoSolve.Core.Model.DataModel;
using SokoSolve.Core.UI.Nodes.Actions;
using SokoSolve.Core.UI.Nodes.Effects;

namespace SokoSolve.Core.UI.Nodes.Specific{
    class NodeTitle : NodeEffectText
    {
        public NodeTitle(GameUI myGameUI, int myDepth) : 
            base(myGameUI, 
                myDepth, 
                myGameUI.Puzzle.Details.Name,
                new Font("Lucida Console", 17f),
                new SolidBrush(Color.Yellow),
                new SolidBrush(Color.DarkOrange),
                new VectorInt(myGameUI.GameCoords.WindowRegion.TopMiddle.Add(-50, 3)))
        {
            secondLine = new NodeEffectText(myGameUI, myDepth - 1, "Sokoban rocks!", CurrentAbsolute.Add(0, 30));
            secondLine.Brush = new SolidBrush(secondLineColour);
            secondLine.Font = new Font("Arial", 11f);
            secondLine.IsVisible = false;

            currentLine = 0;
            lines = GetTextLines().ToArray();

            myGameUI.Add(secondLine);

            chain = new ActionChain();
            chain.Add(new ActionMethod(SelectNextMessage));
            chain.Add(new ActionCounter(20, 250, 4, new ActionDelegate(SetAlpha))); // FadeIn    
            chain.Add(new ActionCounter(0, 50)); // wait
            chain.Add(new ActionCounter(250, 0, -7, new ActionDelegate(SetAlpha))); // FadeOut
            chain.Add(new ActionRetartChain(chain));

            chain.Init();
        }

        List<string> GetTextLines()
        {
            List<string> txt = new List<string>();

            GenericDescription desc = GameUI.Puzzle.Library.Consolidate(GameUI.Puzzle);

            if (!string.IsNullOrEmpty(desc.Description)) txt.Add(desc.Description);
            if (desc.DateSpecified) txt.Add(string.Format("Created: {0}", desc.Date.ToLongDateString()));
            if (!string.IsNullOrEmpty(desc.Comments)) txt.Add(desc.Comments);
            if (!string.IsNullOrEmpty(desc.License)) txt.Add("License: " +desc.License);
            if (desc.Author != null)
            {
                if (!string.IsNullOrEmpty(desc.Author.Name)) txt.Add(desc.Author.Name);
                if (!string.IsNullOrEmpty(desc.Author.Homepage)) txt.Add(desc.Author.Homepage);
            }
            return txt;
        }

        private Color secondLineColour = Color.Sienna;


        bool SetAlpha(NodeAction current)
        {
            secondLine.IsVisible = true;
            ActionCounter ctr = current as ActionCounter;
            if (ctr != null)
            {
                secondLine.Brush = new SolidBrush(Color.FromArgb(ctr.Current, Color.Salmon));
                secondLine.BrushShaddow = new SolidBrush(Color.FromArgb(ctr.Current, Color.Black));
            }
            return true;
        }

        private readonly int maxSecondLineChars = 70;

        bool SelectNextMessage(NodeAction current)
        {
            secondLine.Text = lines[currentLine];
            if (secondLine.Text.Length > maxSecondLineChars)
            {
                secondLine.Text = secondLine.Text.Substring(0, maxSecondLineChars) + "...";
            }
            currentLine++;
            if (currentLine >= lines.Length) currentLine = 0;
            return true;
        }

       

        public override void doStep()
        {
            base.doStep();

            chain.PerformStep();

            // Redock and Resize second line
            secondLine.CurrentAbsolute = new VectorInt(GameUI.GameCoords.WindowRegion.TopMiddle.Subtract(secondLine.Size.Width/2,-30));
        }

        private ActionChain chain;
        private NodeEffectText secondLine;
        private string[] lines;
        private int currentLine;
    }
}

www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.