Click here to Skip to main content
15,891,372 members
Articles / Game Development

Learning XNA 2D Engine IceCream With 1945 Demo Project

Rate me:
Please Sign up or sign in to vote.
5.00/5 (13 votes)
8 Aug 2012CPOL16 min read 66.7K   2.3K   51  
IceCream1945 is a demonstration of XNA and the IceCream 2D library in a 2D top-down scrolling shooter similar to 1942 for the NES.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

namespace Milkshake.Editors.Components
{
    public delegate void ValueChangedEventHandler(object sender, EventArgs e);
    public class AutoControl : UserControl
    {
        private bool _initialized;
        private String _previousValue;
        private String _defaultValue;
        public ValueChangedEventHandler ValueChanged;

        protected int LabelPadding
        {
            get { return 0; }
        }

        public AutoControl()
        {

        }

        public AutoControl(String defaultValue)
        {
            _initialized = false;
            _defaultValue = defaultValue;
        }

        public virtual void SetFriendlyName(String value)
        {

        }

        public virtual void SetFriendlyNameWidth(int width)
        {

        }

        public virtual void SetValue(String value)
        {
            if (_initialized == true && _previousValue != null && _previousValue != value)
            {
                MilkshakeForm.Instance.SceneWasModified = true;                
            }
            _initialized = true;
            _previousValue = value;
        }

        protected virtual bool IsValueValid(string value)
        {
            return true;
        }

        protected virtual void RestoreValue(String errorMessage)
        {
            if (_initialized)
            {
                SetValue(_previousValue);
                MilkshakeForm.ShowErrorMessage(errorMessage);
            }
            else
            {
                SetValue(_defaultValue);
            }
        }

        public virtual object GetValue()
        {
            return null;
        }

        protected void OnValueChanged(EventArgs e)
        {
            if (ValueChanged != null)
            {
                ValueChanged(this, e);
            }
        }        
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions